<html>
<head>
<META http-equiv="Content-Type" content="text/html; charset=utf-8">
<LINK href="diff.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="nav.js"></script>
</head>
<body>
<div id="left" class="src">
<pre>
<a id='leftstart' tid='rightstart'></a>
<a id='6751' tid='6752' class='u'>;;; paredit.el --- minor mode for editing parentheses  -*- Mode: Emacs-Lisp -*-
</a>
<span class='d'>;; Copyright (C) 2005--2010 Taylor R. Campbell
</span>
<a id='6753' tid='6754' class='u'>;; Author: Taylor R. Campbell
</a><span class='d'>;; Version: 22
</span><a id='6755' tid='6756' class='u'>;; Created: 2005-07-31
</a><a id='6757' tid='6758' class='u'>;; Keywords: lisp
</a>
<a id='6759' tid='6760' class='u'>;; Paredit is free software: you can redistribute it and/or modify it
</a><a id='6761' tid='6762' class='u'>;; under the terms of the GNU General Public License as published by
</a><a id='6763' tid='6764' class='u'>;; the Free Software Foundation, either version 3 of the License, or
</a><a id='6765' tid='6766' class='u'>;; (at your option) any later version.
</a><a id='6767' tid='6768' class='u'>;;
</a><a id='6769' tid='6770' class='u'>;; Paredit is distributed in the hope that it will be useful, but
</a><a id='6771' tid='6772' class='u'>;; WITHOUT ANY WARRANTY; without even the implied warranty of
</a><a id='6773' tid='6774' class='u'>;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
</a><a id='6775' tid='6776' class='u'>;; GNU General Public License for more details.
</a><a id='6777' tid='6778' class='u'>;;
</a><a id='6779' tid='6780' class='u'>;; You should have received a copy of the GNU General Public License
</a><a id='6781' tid='6782' class='u'>;; along with paredit.  If not, see &lt;http://www.gnu.org/licenses/&gt;.
</a>
<a id='6783' tid='6784' class='u'>;;; This file is permanently stored at
</a><span class='d'>;;;   &lt;http://mumble.net/~campbell/emacs/paredit-22.el&gt;.
</span><a id='6785' tid='6786' class='u'>;;;
</a><a id='6787' tid='6788' class='u'>;;; The currently released version of paredit is available at
</a><a id='6789' tid='6790' class='u'>;;;   &lt;http://mumble.net/~campbell/emacs/paredit.el&gt;.
</a><a id='6791' tid='6792' class='u'>;;;
</a><a id='6793' tid='6794' class='u'>;;; The latest beta version of paredit is available at
</a><a id='6795' tid='6796' class='u'>;;;   &lt;http://mumble.net/~campbell/emacs/paredit-beta.el&gt;.
</a><a id='6797' tid='6798' class='u'>;;;
</a><a id='6799' tid='6800' class='u'>;;; Release notes are available at
</a><a id='6801' tid='6802' class='u'>;;;   &lt;http://mumble.net/~campbell/emacs/paredit.release&gt;.
</a>
<a id='6803' tid='6804' class='u'>;;; Install paredit by placing `paredit.el&#39; in `/path/to/elisp&#39;, a
</a><a id='6805' tid='6806' class='u'>;;; directory of your choice, and adding to your .emacs file:
</a><a id='6807' tid='6808' class='u'>;;;
</a><a id='6809' tid='6810' class='u'>;;;   (add-to-list &#39;load-path &quot;/path/to/elisp&quot;)
</a><a id='6811' tid='6812' class='u'>;;;   (autoload &#39;enable-paredit-mode &quot;paredit&quot;
</a><a id='6813' tid='6814' class='u'>;;;     &quot;Turn on pseudo-structural editing of Lisp code.&quot;
</a><a id='6815' tid='6816' class='u'>;;;     t)
</a><a id='6817' tid='6818' class='u'>;;;
</a><span class='d'>;;; Enable Paredit Mode on the fly with `M-x enable-paredit-mode RET&#39;,
</span><span class='d'>;;; or always enable it in a major mode `M&#39; (e.g., `lisp&#39;) with:
</span><a id='6819' tid='6820' class='u'>;;;
</a><a id='6821' tid='6822' class='u'>;;;   (add-hook M-mode-hook &#39;enable-paredit-mode)
</a><a id='6823' tid='6824' class='u'>;;;
</a><a id='6825' tid='6826' class='u'>;;; Customize paredit using `eval-after-load&#39;:
</a><a id='6827' tid='6828' class='u'>;;;
</a><a id='6829' tid='6830' class='u'>;;;   (eval-after-load &#39;paredit
</a><span class='d'>;;;     &#39;(progn ...redefine keys, &c....))
</span><span class='d'>;;;
</span><span class='d'>;;; Paredit should run in GNU Emacs 21 or later and XEmacs 21.5 or
</span><span class='d'>;;; later.  Paredit is highly unlikely to work in earlier versions of
</span><span class='d'>;;; GNU Emacs, and it may have obscure problems in earlier versions of
</span><span class='d'>;;; XEmacs due to the way its syntax parser reports conditions, as a
</span><span class='d'>;;; result of which the code that uses the syntax parser must mask all
</span><span class='d'>;;; error conditions, not just those generated by the syntax parser.
</span><span class='d'>;;;
</span><span class='d'>;;; Questions, bug reports, comments, feature suggestions, &c., may be
</span><span class='d'>;;; addressed via email to the author&#39;s surname at mumble.net or via
</span><span class='d'>;;; IRC to the user named Riastradh on irc.freenode.net in the #paredit
</span><span class='d'>;;; channel.
</span><span class='d'>;;;
</span><span class='d'>;;; Please contact the author rather than forking your own versions, to
</span><span class='d'>;;; prevent the dissemination of random variants floating about the
</span><span class='d'>;;; internet unbeknownst to the author.  Laziness is not an excuse:
</span><span class='d'>;;; your laziness costs me confusion and time trying to support
</span><span class='d'>;;; paredit, so if you fork paredit, you make the world a worse place.
</span><span class='d'>;;;
</span><span class='d'>;;; *** WARNING *** IMPORTANT *** DO NOT SUBMIT BUGS BEFORE READING ***
</span><span class='d'>;;;
</span><span class='d'>;;; If you plan to submit a bug report, where some sequence of keys in
</span><span class='d'>;;; Paredit Mode, or some sequence of paredit commands, doesn&#39;t do what
</span><span class='d'>;;; you wanted, then it is helpful to isolate an example in a very
</span><span class='d'>;;; small buffer, and it is **ABSOLUTELY**ESSENTIAL** that you supply,
</span><span class='d'>;;; along with the sequence of keys or commands,
</span><span class='d'>;;;
</span><span class='d'>;;;   (1) the version of Emacs,
</span><span class='d'>;;;   (2) the version of paredit.el[*], and
</span><span class='d'>;;;   (3) the **COMPLETE** state of the buffer used to reproduce the
</span><span class='d'>;;;       problem, including major mode, minor modes, local key
</span><span class='d'>;;;       bindings, entire contents of the buffer, leading line breaks
</span><span class='d'>;;;       or spaces, &c.
</span><span class='d'>;;;
</span><span class='d'>;;; It is often extremely difficult to reproduce problems, especially
</span><span class='d'>;;; with commands such as `paredit-kill&#39;.  If you do not supply **ALL**
</span><span class='d'>;;; of this information, then it is highly probable that I cannot
</span><span class='d'>;;; reproduce your problem no matter how hard I try, and the effect of
</span><span class='d'>;;; submitting a bug without this information is only to waste your
</span><span class='d'>;;; time and mine.  So, please, include all of the above information.
</span><a id='6831' tid='6832' class='u'>;;;
</a><span class='d'>;;; [*] If you are using a beta version of paredit, be sure that you
</span><span class='d'>;;;     are using the *latest* edition of the beta version, available
</span><span class='d'>;;;     at &lt;http://mumble.net/~campbell/emacs/paredit-beta.el&gt;.  If you
</span><span class='d'>;;;     are not using a beta version, then upgrade either to that or to
</span><span class='d'>;;;     the latest release version; I cannot support older versions,
</span><span class='d'>;;;     and I can&#39;t fathom any reason why you might be using them.  So
</span><span class='d'>;;;     the answer to item (2) should be either `release&#39; or `beta&#39;.
</span>
<span class='d'>;;; The paredit minor mode, Paredit Mode, binds a number of simple
</span><span class='d'>;;; keys, notably `(&#39;, `)&#39;, `&quot;&#39;, and `\&#39;, to commands that more
</span><span class='d'>;;; carefully insert S-expression structures in the buffer.  The
</span><span class='d'>;;; parenthesis delimiter keys (round or square) are defined to insert
</span><span class='d'>;;; parenthesis pairs and move past the closing delimiter,
</span><span class='d'>;;; respectively; the double-quote key is multiplexed to do both, and
</span><span class='d'>;;; also to insert an escape if within a string; and backslashes prompt
</span><span class='d'>;;; the user for the next character to input, because a lone backslash
</span><span class='d'>;;; can break structure inadvertently.  These all have their ordinary
</span><span class='d'>;;; behaviour when inside comments, and, outside comments, if truly
</span><span class='d'>;;; necessary, you can insert them literally with `C-q&#39;.
</span><span class='d'>;;;
</span><span class='d'>;;; The key bindings are designed so that when typing new code in
</span><span class='d'>;;; Paredit Mode, you can generally use exactly the same keystrokes as
</span><span class='d'>;;; you would have used without Paredit Mode.  Earlier versions of
</span><span class='d'>;;; paredit.el did not conform to this, because Paredit Mode bound `)&#39;
</span><span class='d'>;;; to a command that would insert a newline.  Now `)&#39; is bound to a
</span><span class='d'>;;; command that does not insert a newline, and `M-)&#39; is bound to the
</span><span class='d'>;;; command that inserts a newline.  To revert to the former behaviour,
</span><span class='d'>;;; add the following forms to an `eval-after-load&#39; form for paredit.el
</span><span class='d'>;;; in your .emacs file:
</span><span class='d'>;;;
</span><span class='d'>;;;   (define-key paredit-mode-map (kbd &quot;)&quot;)
</span><span class='d'>;;;     &#39;paredit-close-round-and-newline)
</span><span class='d'>;;;   (define-key paredit-mode-map (kbd &quot;M-)&quot;)
</span><span class='d'>;;;     &#39;paredit-close-round)
</span><span class='d'>;;;
</span><span class='d'>;;; Paredit Mode also binds the usual keys for deleting and killing, so
</span><span class='d'>;;; that they will not destroy any S-expression structure by killing or
</span><span class='d'>;;; deleting only one side of a parenthesis or quote pair.  If the
</span><span class='d'>;;; point is on a closing delimiter, `DEL&#39; will move left over it; if
</span><span class='d'>;;; it is on an opening delimiter, `C-d&#39; will move right over it.  Only
</span><span class='d'>;;; if the point is between a pair of delimiters will `C-d&#39; or `DEL&#39;
</span><span class='d'>;;; delete them, and in that case it will delete both simultaneously.
</span><span class='d'>;;; `M-d&#39; and `M-DEL&#39; kill words, but skip over any S-expression
</span><span class='d'>;;; structure.  `C-k&#39; kills from the start of the line, either to the
</span><span class='d'>;;; line&#39;s end, if it contains only balanced expressions; to the first
</span><span class='d'>;;; closing delimiter, if the point is within a form that ends on the
</span><span class='d'>;;; line; or up to the end of the last expression that starts on the
</span><span class='d'>;;; line after the point.
</span><span class='d'>;;;
</span><span class='d'>;;; The behaviour of the commands for deleting and killing can be
</span><span class='d'>;;; overridden by passing a `C-u&#39; prefix argument: `C-u DEL&#39; will
</span><span class='d'>;;; delete a character backward, `C-u C-d&#39; will delete a character
</span><span class='d'>;;; forward, and `C-u C-k&#39; will kill text from the point to the end of
</span><span class='d'>;;; the line, irrespective of the S-expression structure in the buffer.
</span><span class='d'>;;; This can be used to fix mistakes in a buffer, but should generally
</span><span class='d'>;;; be avoided.
</span><span class='d'>;;;
</span><span class='d'>;;; Paredit performs automatic reindentation as locally as possible, to
</span><span class='d'>;;; avoid interfering with custom indentation used elsewhere in some
</span><span class='d'>;;; S-expression.  Only the advanced S-expression manipulation commands
</span><span class='d'>;;; automatically reindent, and only the forms that were immediately
</span><span class='d'>;;; operated upon (and their subforms).
</span><span class='d'>;;;
</span><span class='d'>;;; This code is written for clarity, not efficiency.  It frequently
</span><span class='d'>;;; walks over S-expressions redundantly.  If you have problems with
</span><span class='d'>;;; the time it takes to execute some of the commands, let me know, but
</span><span class='d'>;;; first be sure that what you&#39;re doing is reasonable: it is
</span><span class='d'>;;; preferable to avoid immense S-expressions in code anyway.
</span>
<span class='d'>;;; This assumes Unix-style LF line endings.
</span>
<span class='d'>(defconst paredit-version 22)</span>
(<a id='6833' tid='6834' class='u'>defconst</a> <a id='6835' tid='6836' class='u'>paredit-beta-p</a> <a id='6837' tid='6838' class='u'>nil</a>)

(<a id='6915' tid='6916' class='u'>eval-and-compile</a>

  (<a id='6897' tid='6898' class='u'>defun</a> <a id='6899' tid='6900' class='u'>paredit-xemacs-p</a> ()
    <a id='6901' tid='6902' class='u'>;; No idea where I got this definition from.  Edward O&#39;Connor
</a>    <a id='6903' tid='6904' class='u'>;; (hober in #emacs) suggested the current definition.
</a>    <a id='6905' tid='6906' class='u'>;;   (and (boundp &#39;running-xemacs)
</a>    <a id='6907' tid='6908' class='u'>;;        running-xemacs)
</a>    (<a id='6909' tid='6910' class='u'>featurep</a> <a id='6911' tid='6912' class='u'>&#39;</a><a id='6913' tid='6914' class='u'>xemacs</a>))

  (<a id='6839' tid='6840' class='u'>defun</a> <a id='6841' tid='6842' class='u'>paredit-gnu-emacs-p</a> ()
    <a id='6843' tid='6844' class='u'>;++ This could probably be improved.
</a>    (<a id='6845' tid='6846' class='u'>not</a> (<a id='6847' tid='6848' class='u'>paredit-xemacs-p</a>)))

  (<a id='6917' tid='6918' class='u'>defmacro</a> <a id='6919' tid='6920' class='u'>xcond</a> (<a id='6921' tid='6922' class='u'>&rest</a> <a id='6923' tid='6924' class='u'>clauses</a>)
    <a id='6925' tid='6926' class='u'>&quot;Exhaustive COND.
Signal an error if no clause matches.&quot;</a>
    <a id='6927' tid='6928' class='u'>`</a>(<a id='6929' tid='6930' class='u'>cond</a> <a id='6931' tid='6932' class='u'>,</a><a id='6933' tid='6934' class='u'>@clauses</a>
           (<a id='6935' tid='6936' class='u'>t</a> (<a id='6937' tid='6938' class='u'>error</a> <a id='6939' tid='6940' class='u'>&quot;XCOND lost.&quot;</a>))))

  (<a id='6941' tid='6942' class='u'>defalias</a> <a id='6943' tid='6944' class='u'>&#39;</a><a id='6945' tid='6946' class='u'>paredit-warn</a> (<a id='6947' tid='6948' class='u'>if</a> (<a id='6949' tid='6950' class='u'>fboundp</a> <a id='6951' tid='6952' class='u'>&#39;</a><a id='6953' tid='6954' class='u'>warn</a>) <a id='6955' tid='6956' class='u'>&#39;</a><a id='6957' tid='6958' class='u'>warn</a> <a id='6959' tid='6960' class='u'>&#39;</a><a id='6961' tid='6962' class='u'>message</a>))

  (<a id='6849' tid='6850' class='u'>defvar</a> <a id='6851' tid='6852' class='u'>paredit-sexp-error-type</a>
    (<a id='6853' tid='6854' class='u'>with-temp-buffer</a>
      (<a id='6855' tid='6856' class='u'>insert</a> <a id='6857' tid='6858' class='u'>&quot;(&quot;</a>)
      (<a id='6859' tid='6860' class='u'>condition-case</a> <a id='6861' tid='6862' class='u'>condition</a>
          (<a id='6863' tid='6864' class='u'>backward-sexp</a>)
        (<a id='6865' tid='6866' class='u'>error</a> (<a id='6867' tid='6868' class='u'>if</a> (<a id='6869' tid='6870' class='u'>eq</a> (<a id='6871' tid='6872' class='u'>car</a> <a id='6873' tid='6874' class='u'>condition</a>) <a id='6875' tid='6876' class='u'>&#39;</a><a id='6877' tid='6878' class='u'>error</a>)
                   (<a id='6879' tid='6880' class='u'>paredit-warn</a> <a id='6881' tid='6882' class='u'>&quot;%s%s%s%s%s&quot;</a>
                                 <a id='6883' tid='6884' class='u'>&quot;Paredit is unable to discriminate&quot;</a>
                                 <a id='6885' tid='6886' class='u'>&quot; S-expression parse errors from&quot;</a>
                                 <a id='6887' tid='6888' class='u'>&quot; other errors. &quot;</a>
                                 <a id='6889' tid='6890' class='u'>&quot; This may cause obscure problems. &quot;</a>
                                 <a id='6891' tid='6892' class='u'>&quot; Please upgrade Emacs.&quot;</a>))
               (<a id='6893' tid='6894' class='u'>car</a> <a id='6895' tid='6896' class='u'>condition</a>)))))

  (<a id='6963' tid='6964' class='u'>defmacro</a> <a id='6965' tid='6966' class='u'>paredit-handle-sexp-errors</a> (<a id='6967' tid='6968' class='u'>body</a> <a id='6969' tid='6970' class='u'>&rest</a> <a id='6971' tid='6972' class='u'>handler</a>)
    <a id='6973' tid='6974' class='u'>`</a>(<a id='6975' tid='6976' class='u'>condition-case</a> ()
         <a id='6977' tid='6978' class='u'>,</a><a id='6979' tid='6980' class='u'>body</a>
       (<a id='6981' tid='6982' class='u'>,</a><a id='6983' tid='6984' class='u'>paredit-sexp-error-type</a> <a id='6985' tid='6986' class='u'>,</a><a id='6987' tid='6988' class='u'>@handler</a>)))

  (<a id='6989' tid='6990' class='u'>put</a> <a id='6991' tid='6992' class='u'>&#39;</a><a id='6993' tid='6994' class='u'>paredit-handle-sexp-errors</a> <a id='6995' tid='6996' class='u'>&#39;</a><a id='6997' tid='6998' class='u'>lisp-indent-function</a> <a id='6999' tid='7000' class='u'>1</a>)

  (<a id='7001' tid='7002' class='u'>defmacro</a> <a id='7003' tid='7004' class='u'>paredit-ignore-sexp-errors</a> (<a id='7005' tid='7006' class='u'>&rest</a> <a id='7007' tid='7008' class='u'>body</a>)
    <a id='7009' tid='7010' class='u'>`</a>(<a id='7011' tid='7012' class='u'>paredit-handle-sexp-errors</a> (<a id='7013' tid='7014' class='u'>progn</a> <a id='7015' tid='7016' class='u'>,</a><a id='7017' tid='7018' class='u'>@body</a>)
       <a id='7019' tid='7020' class='u'>nil</a>))

  (<a id='7021' tid='7022' class='u'>put</a> <a id='7023' tid='7024' class='u'>&#39;</a><a id='7025' tid='7026' class='u'>paredit-ignore-sexp-errors</a> <a id='7027' tid='7028' class='u'>&#39;</a><a id='7029' tid='7030' class='u'>lisp-indent-function</a> <a id='7031' tid='7032' class='u'>0</a>)

  <a id='7033' tid='7034' class='u'>nil</a>)

<a id='7035' tid='7036' class='u'>;;;; Minor Mode Definition
</a>
(<a id='5301' tid='5302' class='u'>defvar</a> <a id='5303' tid='5304' class='u'>paredit-mode-map</a> (<a id='5305' tid='5306' class='u'>make-sparse-keymap</a>)
  <a id='5307' tid='5308' class='u'>&quot;Keymap for the paredit minor mode.&quot;</a>)

<a id='7037' tid='7038' class='u'>;;;###autoload
</a>(<a id='5293' tid='5294' class='u'>define-minor-mode</a> <a id='5295' tid='5296' class='u'>paredit-mode</a>
  <span class='d'>&quot;Minor mode for pseudo-structurally editing Lisp code.
With a prefix argument, enable Paredit Mode even if there are
  imbalanced parentheses in the buffer.
Paredit behaves badly if parentheses are imbalanced, so exercise
  caution when forcing Paredit Mode to be enabled, and consider
  fixing imbalanced parentheses instead.
\\&lt;paredit-mode-map&gt;&quot;</span>
  <a id='5297' tid='5298' class='u'>:lighter</a> <a id='5299' tid='5300' class='u'>&quot; Paredit&quot;</a>
  <span class='d'>;; If we&#39;re enabling paredit-mode, the prefix to this code that
</span>  <span class='d'>;; DEFINE-MINOR-MODE inserts will have already set PAREDIT-MODE to
</span>  <span class='d'>;; true.  If this is the case, then first check the parentheses, and
</span>  <span class='d'>;; if there are any imbalanced ones we must inhibit the activation of
</span>  <span class='d'>;; paredit mode.  We skip the check, though, if the user supplied a
</span>  <span class='d'>;; prefix argument interactively.
</span>  (<a id='717' tid='718' class='m'>if</a> (<a id='719' tid='720' class='m'>and</a> <a id='721' tid='722' class='m'>paredit-mode</a>
           (<a id='723' tid='724' class='m'>not</a> <a id='725' tid='726' class='m'>current-prefix-arg</a>))
      (<span class='d'>if</span> <span class='d'>(not (fboundp &#39;check-parens))</span>
          <span class='d'>(paredit-warn &quot;`check-parens&#39; is not defined; %s&quot;
                        &quot;be careful of malformed S-expressions.&quot;)</span>
          (<a id='727' tid='728' class='m'>condition-case</a> <a id='729' tid='730' class='m'>condition</a>
              (<a id='731' tid='732' class='m'>check-parens</a>)
            (<span class='d'>error</span> <span class='d'>(setq paredit-mode nil)</span>
                   (<a id='733' tid='734' class='m'>signal</a> (<a id='735' tid='736' class='m'>car</a> <a id='737' tid='738' class='m'>condition</a>) (<a id='739' tid='740' class='m'>cdr</a> <a id='741' tid='742' class='m'>condition</a>)))))))

(<a id='1777' tid='1778' class='u'>defun</a> <a id='1779' tid='1780' class='u'>enable-paredit-mode</a> ()
  <a id='1781' tid='1782' class='u'>&quot;Turn on pseudo-structural editing of Lisp code.&quot;</a>
  (<a id='1783' tid='1784' class='u'>interactive</a>)
  (<a id='1785' tid='1786' class='u'>paredit-mode</a> <a id='1787' tid='1788' class='u'>+1</a>))

(<a id='1765' tid='1766' class='u'>defun</a> <a id='1767' tid='1768' class='u'>disable-paredit-mode</a> ()
  <a id='1769' tid='1770' class='u'>&quot;Turn off pseudo-structural editing of Lisp code.&quot;</a>
  (<a id='1771' tid='1772' class='u'>interactive</a>)
  (<a id='1773' tid='1774' class='u'>paredit-mode</a> <a id='1775' tid='1776' class='u'>-1</a>))

(<a id='2203' tid='2204' class='u'>defvar</a> <a id='2205' tid='2206' class='u'>paredit-backward-delete-key</a>
  (<a id='2207' tid='2208' class='u'>xcond</a> ((<a id='2209' tid='2210' class='u'>paredit-xemacs-p</a>)    <a id='2211' tid='2212' class='u'>&quot;BS&quot;</a>)
         ((<a id='2213' tid='2214' class='u'>paredit-gnu-emacs-p</a>) <a id='2215' tid='2216' class='u'>&quot;DEL&quot;</a>)))

(<a id='3329' tid='3330' class='u'>defvar</a> <a id='3331' tid='3332' class='u'>paredit-forward-delete-keys</a>
  (<a id='3333' tid='3334' class='u'>xcond</a> ((<a id='3335' tid='3336' class='u'>paredit-xemacs-p</a>)    <a id='3337' tid='3338' class='u'>&#39;</a>(<a id='3339' tid='3340' class='u'>&quot;DEL&quot;</a>))
         ((<a id='3341' tid='3342' class='u'>paredit-gnu-emacs-p</a>) <a id='3343' tid='3344' class='u'>&#39;</a>(<a id='3345' tid='3346' class='u'>&quot;&lt;delete&gt;&quot;</a> <a id='3347' tid='3348' class='u'>&quot;&lt;deletechar&gt;&quot;</a>))))

<a id='7039' tid='7040' class='u'>;;;; Paredit Keys
</a>
<a id='7041' tid='7042' class='u'>;;; Separating the definition and initialization of this variable
</a><a id='7043' tid='7044' class='u'>;;; simplifies the development of paredit, since re-evaluating DEFVAR
</a><a id='7045' tid='7046' class='u'>;;; forms doesn&#39;t actually do anything.
</a>
(<a id='2617' tid='2618' class='u'>defvar</a> <a id='2619' tid='2620' class='u'>paredit-commands</a> <a id='2621' tid='2622' class='u'>nil</a>
  <a id='2623' tid='2624' class='u'>&quot;List of paredit commands with their keys and examples.&quot;</a>)

<a id='7047' tid='7048' class='u'>;;; Each specifier is of the form:
</a><a id='7049' tid='7050' class='u'>;;;   (key[s] function (example-input example-output) ...)
</a><a id='7051' tid='7052' class='u'>;;; where key[s] is either a single string suitable for passing to KBD
</a><a id='7053' tid='7054' class='u'>;;; or a list of such strings.  Entries in this list may also just be
</a><a id='7055' tid='7056' class='u'>;;; strings, in which case they are headings for the next entries.
</a>
(<a id='743' tid='744' class='m'>progn</a> (<a id='745' tid='746' class='m'>setq</a> <a id='747' tid='748' class='m'>paredit-commands</a>
 <a id='749' tid='750' class='m'>`</a>(
   <span class='d'>&quot;Basic Insertion Commands&quot;</span>
   (<a id='751' tid='752' class='m'>&quot;(&quot;</a>         <a id='753' tid='754' class='m'>paredit-open-round</a>
                (<a id='755' tid='756' class='m'>&quot;(a b |c d)&quot;</a>
                 <a id='757' tid='758' class='m'>&quot;(a b (|) c d)&quot;</a>)
                (<a id='759' tid='760' class='m'>&quot;(foo \&quot;bar |baz\&quot; quux)&quot;</a>
                 <a id='761' tid='762' class='m'>&quot;(foo \&quot;bar (|baz\&quot; quux)&quot;</a>))
   (<a id='525' tid='526' class='m'>&quot;)&quot;</a>         <a id='527' tid='528' class='m'>paredit-close-round</a>
                (<a id='529' tid='530' class='m'>&quot;(a b |c   )&quot;</a> <a id='531' tid='532' class='m'>&quot;(a b c)|&quot;</a>)
                (<a id='533' tid='534' class='m'>&quot;; Hello,| world!&quot;</a>
                 <a id='535' tid='536' class='m'>&quot;; Hello,)| world!&quot;</a>))
   (<a id='459' tid='460' class='m'>&quot;M-)&quot;</a>       <a id='461' tid='462' class='m'>paredit-close-round-and-newline</a>
                (<a id='463' tid='464' class='m'>&quot;(defun f (x|  ))&quot;</a>
                 <a id='465' tid='466' class='m'>&quot;(defun f (x)\n  |)&quot;</a>)
                (<a id='467' tid='468' class='m'>&quot;; (Foo.|&quot;</a>
                 <a id='469' tid='470' class='m'>&quot;; (Foo.)|&quot;</a>))
   <span class='d'>(&quot;[&quot;         paredit-open-square
                (&quot;(a b |c d)&quot;
                 &quot;(a b [|] c d)&quot;)
                (&quot;(foo \&quot;bar |baz\&quot; quux)&quot;
                 &quot;(foo \&quot;bar [baz\&quot; quux)&quot;))</span>
   (<a id='425' tid='426' class='m'>&quot;]&quot;</a>         <a id='427' tid='428' class='m'>paredit-close-square</a>
                (<a id='429' tid='430' class='m'>&quot;(define-key keymap [frob|  ] &#39;frobnicate)&quot;</a>
                 <a id='431' tid='432' class='m'>&quot;(define-key keymap [frob]| &#39;frobnicate)&quot;</a>)
                (<a id='433' tid='434' class='m'>&quot;; [Bar.|&quot;</a>
                 <a id='435' tid='436' class='m'>&quot;; [Bar.]|&quot;</a>))
   <span class='d'>(&quot;\&quot;&quot;        paredit-doublequote
                (&quot;(frob grovel |full lexical)&quot;
                 &quot;(frob grovel \&quot;|\&quot; full lexical)&quot;)
                (&quot;(foo \&quot;bar |baz\&quot; quux)&quot;
                 &quot;(foo \&quot;bar \\\&quot;|baz\&quot; quux)&quot;))</span>
   (<a id='315' tid='316' class='m'>&quot;M-\&quot;&quot;</a>      <a id='317' tid='318' class='m'>paredit-meta-doublequote</a>
                (<a id='319' tid='320' class='m'>&quot;(foo \&quot;bar |baz\&quot; quux)&quot;</a>
                 <a id='321' tid='322' class='m'>&quot;(foo \&quot;bar baz\&quot;\n     |quux)&quot;</a>)
                (<a id='323' tid='324' class='m'>&quot;(foo |(bar #\\x \&quot;baz \\\\ quux\&quot;) zot)&quot;</a>
                 <a id='325' tid='326' class='m'>,</a>(<a id='327' tid='328' class='m'>concat</a> <a id='329' tid='330' class='m'>&quot;(foo \&quot;|(bar #\\\\x \\\&quot;baz \\\\&quot;</a>
                          <a id='331' tid='332' class='m'>&quot;\\\\ quux\\\&quot;)\&quot; zot)&quot;</a>)))
   <span class='d'>(&quot;\\&quot;        paredit-backslash
                (&quot;(string #|)\n  ; Escaping character... (x)&quot;
                 &quot;(string #\\x|)&quot;)
                (&quot;\&quot;foo|bar\&quot;\n  ; Escaping character... (\&quot;)&quot;
                 &quot;\&quot;foo\\\&quot;|bar\&quot;&quot;))</span>
   <span class='d'>(&quot;;&quot;         paredit-semicolon
                (&quot;|(frob grovel)&quot;
                 &quot;;|(frob grovel)&quot;)
                (&quot;(frob |grovel)&quot;
                 &quot;(frob ;grovel\n)&quot;)
                (&quot;(frob |grovel (bloit\n               zargh))&quot;
                 &quot;(frob ;|grovel\n (bloit\n  zargh))&quot;)
                (&quot;(frob grovel)          |&quot;
                 &quot;(frob grovel)          ;|&quot;))</span>
   <span class='d'>(&quot;M-;&quot;       paredit-comment-dwim
                (&quot;(foo |bar)   ; baz&quot;
                 &quot;(foo bar)                               ; |baz&quot;)
                (&quot;(frob grovel)|&quot;
                 &quot;(frob grovel)                           ;|&quot;)
                (&quot;    (foo bar)\n|\n    (baz quux)&quot;
                 &quot;    (foo bar)\n    ;; |\n    (baz quux)&quot;)
                (&quot;    (foo bar) |(baz quux)&quot;
                 &quot;    (foo bar)\n    ;; |\n    (baz quux)&quot;)
                (&quot;|(defun hello-world ...)&quot;
                 &quot;;;; |\n(defun hello-world ...)&quot;))</span>

   <span class='d'>(&quot;C-j&quot;       paredit-newline
                (&quot;(let ((n (frobbotz))) |(display (+ n 1)\nport))&quot;
                 ,(concat &quot;(let ((n (frobbotz)))&quot;
                          &quot;\n  |(display (+ n 1)&quot;
                          &quot;\n            port))&quot;)))</span>

   <span class='d'>&quot;Deleting & Killing&quot;</span>
   ((<a id='225' tid='226' class='m'>&quot;C-d&quot;</a> <a id='227' tid='228' class='m'>,</a><a id='229' tid='230' class='m'>@paredit-forward-delete-keys</a>)
                <a id='231' tid='232' class='m'>paredit-forward-delete</a>
                (<a id='233' tid='234' class='m'>&quot;(quu|x \&quot;zot\&quot;)&quot;</a> <a id='235' tid='236' class='m'>&quot;(quu| \&quot;zot\&quot;)&quot;</a>)
                (<a id='237' tid='238' class='m'>&quot;(quux |\&quot;zot\&quot;)&quot;</a>
                 <a id='239' tid='240' class='m'>&quot;(quux \&quot;|zot\&quot;)&quot;</a>
                 <a id='241' tid='242' class='m'>&quot;(quux \&quot;|ot\&quot;)&quot;</a>)
                (<a id='243' tid='244' class='m'>&quot;(foo (|) bar)&quot;</a> <a id='245' tid='246' class='m'>&quot;(foo | bar)&quot;</a>)
                (<a id='247' tid='248' class='m'>&quot;|(foo bar)&quot;</a> <a id='249' tid='250' class='m'>&quot;(|foo bar)&quot;</a>))
   (<a id='173' tid='174' class='m'>,</a><a id='175' tid='176' class='m'>paredit-backward-delete-key</a>
                <a id='177' tid='178' class='m'>paredit-backward-delete</a>
                (<a id='179' tid='180' class='m'>&quot;(\&quot;zot\&quot; q|uux)&quot;</a> <a id='181' tid='182' class='m'>&quot;(\&quot;zot\&quot; |uux)&quot;</a>)
                (<a id='183' tid='184' class='m'>&quot;(\&quot;zot\&quot;| quux)&quot;</a>
                 <a id='185' tid='186' class='m'>&quot;(\&quot;zot|\&quot; quux)&quot;</a>
                 <a id='187' tid='188' class='m'>&quot;(\&quot;zo|\&quot; quux)&quot;</a>)
                (<a id='189' tid='190' class='m'>&quot;(foo (|) bar)&quot;</a> <a id='191' tid='192' class='m'>&quot;(foo | bar)&quot;</a>)
                (<a id='193' tid='194' class='m'>&quot;(foo bar)|&quot;</a> <a id='195' tid='196' class='m'>&quot;(foo bar|)&quot;</a>))
   (<a id='153' tid='154' class='m'>&quot;C-k&quot;</a>       <a id='155' tid='156' class='m'>paredit-kill</a>
                (<a id='157' tid='158' class='m'>&quot;(foo bar)|     ; Useless comment!&quot;</a>
                 <a id='159' tid='160' class='m'>&quot;(foo bar)|&quot;</a>)
                (<a id='161' tid='162' class='m'>&quot;(|foo bar)     ; Useful comment!&quot;</a>
                 <a id='163' tid='164' class='m'>&quot;(|)     ; Useful comment!&quot;</a>)
                (<a id='165' tid='166' class='m'>&quot;|(foo bar)     ; Useless line!&quot;</a>
                 <a id='167' tid='168' class='m'>&quot;|&quot;</a>)
                (<a id='169' tid='170' class='m'>&quot;(foo \&quot;|bar baz\&quot;\n     quux)&quot;</a>
                 <a id='171' tid='172' class='m'>&quot;(foo \&quot;|\&quot;\n     quux)&quot;</a>))
   (<a id='135' tid='136' class='m'>&quot;M-d&quot;</a>       <a id='137' tid='138' class='m'>paredit-forward-kill-word</a>
                (<a id='139' tid='140' class='m'>&quot;|(foo bar)    ; baz&quot;</a>
                 <a id='141' tid='142' class='m'>&quot;(| bar)    ; baz&quot;</a>
                 <a id='143' tid='144' class='m'>&quot;(|)    ; baz&quot;</a>
                 <a id='145' tid='146' class='m'>&quot;()    ;|&quot;</a>)
                (<a id='147' tid='148' class='m'>&quot;;;;| Frobnicate\n(defun frobnicate ...)&quot;</a>
                 <a id='149' tid='150' class='m'>&quot;;;;|\n(defun frobnicate ...)&quot;</a>
                 <a id='151' tid='152' class='m'>&quot;;;;\n(| frobnicate ...)&quot;</a>))
   (<a id='115' tid='116' class='m'>,</a>(<a id='117' tid='118' class='m'>concat</a> <a id='119' tid='120' class='m'>&quot;M-&quot;</a> <a id='121' tid='122' class='m'>paredit-backward-delete-key</a>)
                <a id='123' tid='124' class='m'>paredit-backward-kill-word</a>
                (<a id='125' tid='126' class='m'>&quot;(foo bar)    ; baz\n(quux)|&quot;</a>
                 <a id='127' tid='128' class='m'>&quot;(foo bar)    ; baz\n(|)&quot;</a>
                 <a id='129' tid='130' class='m'>&quot;(foo bar)    ; |\n()&quot;</a>
                 <a id='131' tid='132' class='m'>&quot;(foo |)    ; \n()&quot;</a>
                 <a id='133' tid='134' class='m'>&quot;(|)    ; \n()&quot;</a>))

   <span class='d'>&quot;Movement & Navigation&quot;</span>
   (<a id='103' tid='104' class='m'>&quot;C-M-f&quot;</a>     <a id='105' tid='106' class='m'>paredit-forward</a>
                (<a id='107' tid='108' class='m'>&quot;(foo |(bar baz) quux)&quot;</a>
                 <a id='109' tid='110' class='m'>&quot;(foo (bar baz)| quux)&quot;</a>)
                (<a id='111' tid='112' class='m'>&quot;(foo (bar)|)&quot;</a>
                 <a id='113' tid='114' class='m'>&quot;(foo (bar))|&quot;</a>))
   (<a id='91' tid='92' class='m'>&quot;C-M-b&quot;</a>     <a id='93' tid='94' class='m'>paredit-backward</a>
                (<a id='95' tid='96' class='m'>&quot;(foo (bar baz)| quux)&quot;</a>
                 <a id='97' tid='98' class='m'>&quot;(foo |(bar baz) quux)&quot;</a>)
                (<a id='99' tid='100' class='m'>&quot;(|(foo) bar)&quot;</a>
                 <a id='101' tid='102' class='m'>&quot;|((foo) bar)&quot;</a>))
   <span class='d'>(&quot;C-M-u&quot;     paredit-backward-up)</span>
   <span class='d'>(&quot;C-M-d&quot;     paredit-forward-down)</span>
   <span class='d'>(&quot;C-M-p&quot;     paredit-backward-down)</span>  <span class='d'>; Built-in, these are FORWARD-
</span>   <span class='d'>(&quot;C-M-n&quot;     paredit-forward-up)</span>     <span class='d'>; & BACKWARD-LIST, which have
</span>                                        <span class='d'>; no need given C-M-f & C-M-b.
</span>
   <span class='d'>&quot;Depth-Changing Commands&quot;</span>
   <span class='d'>(&quot;M-(&quot;       paredit-wrap-round
                (&quot;(foo |bar baz)&quot;
                 &quot;(foo (|bar) baz)&quot;))</span>
   <span class='d'>(&quot;M-s&quot;       paredit-splice-sexp
                (&quot;(foo (bar| baz) quux)&quot;
                 &quot;(foo bar| baz quux)&quot;))</span>
   <span class='d'>((&quot;M-&lt;up&gt;&quot; &quot;ESC &lt;up&gt;&quot;)
                paredit-splice-sexp-killing-backward
                (&quot;(foo (let ((x 5)) |(sqrt n)) bar)&quot;
                 &quot;(foo (sqrt n) bar)&quot;))</span>
   <span class='d'>((&quot;M-&lt;down&gt;&quot; &quot;ESC &lt;down&gt;&quot;)
                paredit-splice-sexp-killing-forward
                (&quot;(a (b c| d e) f)&quot;
                 &quot;(a b c f)&quot;))</span>
   (<a id='81' tid='82' class='m'>&quot;M-r&quot;</a>       <a id='83' tid='84' class='m'>paredit-raise-sexp</a>
                (<a id='85' tid='86' class='m'>&quot;(dynamic-wind in (lambda () |body) out)&quot;</a>
                 <a id='87' tid='88' class='m'>&quot;(dynamic-wind in |body out)&quot;</a>
                 <a id='89' tid='90' class='m'>&quot;|body&quot;</a>))

   <span class='d'>&quot;Barfage & Slurpage&quot;</span>
   ((<a id='67' tid='68' class='m'>&quot;C-)&quot;</a> <a id='69' tid='70' class='m'>&quot;C-&lt;right&gt;&quot;</a>)
                <a id='71' tid='72' class='m'>paredit-forward-slurp-sexp</a>
                (<a id='73' tid='74' class='m'>&quot;(foo (bar |baz) quux zot)&quot;</a>
                 <a id='75' tid='76' class='m'>&quot;(foo (bar |baz quux) zot)&quot;</a>)
                (<a id='77' tid='78' class='m'>&quot;(a b ((c| d)) e f)&quot;</a>
                 <a id='79' tid='80' class='m'>&quot;(a b ((c| d) e) f)&quot;</a>))
   ((<a id='57' tid='58' class='m'>&quot;C-}&quot;</a> <a id='59' tid='60' class='m'>&quot;C-&lt;left&gt;&quot;</a>)
                <a id='61' tid='62' class='m'>paredit-forward-barf-sexp</a>
                (<a id='63' tid='64' class='m'>&quot;(foo (bar |baz quux) zot)&quot;</a>
                 <a id='65' tid='66' class='m'>&quot;(foo (bar |baz) quux zot)&quot;</a>))
   ((<a id='41' tid='42' class='m'>&quot;C-(&quot;</a> <a id='43' tid='44' class='m'>&quot;C-M-&lt;left&gt;&quot;</a> <a id='45' tid='46' class='m'>&quot;ESC C-&lt;left&gt;&quot;</a>)
                <a id='47' tid='48' class='m'>paredit-backward-slurp-sexp</a>
                (<a id='49' tid='50' class='m'>&quot;(foo bar (baz| quux) zot)&quot;</a>
                 <a id='51' tid='52' class='m'>&quot;(foo (bar baz| quux) zot)&quot;</a>)
                (<a id='53' tid='54' class='m'>&quot;(a b ((c| d)) e f)&quot;</a>
                 <a id='55' tid='56' class='m'>&quot;(a (b (c| d)) e f)&quot;</a>))
   ((<a id='29' tid='30' class='m'>&quot;C-{&quot;</a> <a id='31' tid='32' class='m'>&quot;C-M-&lt;right&gt;&quot;</a> <a id='33' tid='34' class='m'>&quot;ESC C-&lt;right&gt;&quot;</a>)
                <a id='35' tid='36' class='m'>paredit-backward-barf-sexp</a>
                (<a id='37' tid='38' class='m'>&quot;(foo (bar baz |quux) zot)&quot;</a>
                 <a id='39' tid='40' class='m'>&quot;(foo bar (baz |quux) zot)&quot;</a>))

   <span class='d'>&quot;Miscellaneous Commands&quot;</span>
   (<a id='17' tid='18' class='m'>&quot;M-S&quot;</a>       <a id='19' tid='20' class='m'>paredit-split-sexp</a>
                (<a id='21' tid='22' class='m'>&quot;(hello| world)&quot;</a>
                 <a id='23' tid='24' class='m'>&quot;(hello)| (world)&quot;</a>)
                (<a id='25' tid='26' class='m'>&quot;\&quot;Hello, |world!\&quot;&quot;</a>
                 <a id='27' tid='28' class='m'>&quot;\&quot;Hello, \&quot;| \&quot;world!\&quot;&quot;</a>))
   (<a id='1' tid='2' class='m'>&quot;M-J&quot;</a>       <a id='3' tid='4' class='m'>paredit-join-sexps</a>
                (<a id='5' tid='6' class='m'>&quot;(hello)| (world)&quot;</a>
                 <a id='7' tid='8' class='m'>&quot;(hello| world)&quot;</a>)
                (<a id='9' tid='10' class='m'>&quot;\&quot;Hello, \&quot;| \&quot;world!\&quot;&quot;</a>
                 <a id='11' tid='12' class='m'>&quot;\&quot;Hello, |world!\&quot;&quot;</a>)
                (<a id='13' tid='14' class='m'>&quot;hello-\n|  world&quot;</a>
                 <a id='15' tid='16' class='m'>&quot;hello-|world&quot;</a>))
   <span class='d'>(&quot;C-c C-M-l&quot; paredit-recentre-on-sexp)</span>
   <span class='d'>(&quot;M-q&quot;       paredit-reindent-defun)</span>
   ))
       <a id='763' tid='764' class='m'>nil</a>)                             <span class='d'>; end of PROGN
</span>
<span class='d'>;;;;; Command Examples
</span>
(<a id='7057' tid='7058' class='u'>eval-and-compile</a>
  (<a id='7059' tid='7060' class='u'>defmacro</a> <a id='7061' tid='7062' class='u'>paredit-do-commands</a> (<a id='7063' tid='7064' class='u'>vars</a> <a id='7065' tid='7066' class='u'>string-case</a> <a id='7067' tid='7068' class='u'>&rest</a> <a id='7069' tid='7070' class='u'>body</a>)
    (<a id='7071' tid='7072' class='u'>let</a> ((<a id='7073' tid='7074' class='u'>spec</a>     (<a id='7075' tid='7076' class='u'>nth</a> <a id='7077' tid='7078' class='u'>0</a> <a id='7079' tid='7080' class='u'>vars</a>))
          (<a id='7081' tid='7082' class='u'>keys</a>     (<a id='7083' tid='7084' class='u'>nth</a> <a id='7085' tid='7086' class='u'>1</a> <a id='7087' tid='7088' class='u'>vars</a>))
          (<a id='7089' tid='7090' class='u'>fn</a>       (<a id='7091' tid='7092' class='u'>nth</a> <a id='7093' tid='7094' class='u'>2</a> <a id='7095' tid='7096' class='u'>vars</a>))
          (<a id='7097' tid='7098' class='u'>examples</a> (<a id='7099' tid='7100' class='u'>nth</a> <a id='7101' tid='7102' class='u'>3</a> <a id='7103' tid='7104' class='u'>vars</a>)))
      <a id='7105' tid='7106' class='u'>`</a>(<a id='7107' tid='7108' class='u'>dolist</a> (<a id='7109' tid='7110' class='u'>,</a><a id='7111' tid='7112' class='u'>spec</a> <a id='7113' tid='7114' class='u'>paredit-commands</a>)
         (<a id='7115' tid='7116' class='u'>if</a> (<a id='7117' tid='7118' class='u'>stringp</a> <a id='7119' tid='7120' class='u'>,</a><a id='7121' tid='7122' class='u'>spec</a>)
             <a id='7123' tid='7124' class='u'>,</a><a id='7125' tid='7126' class='u'>string-case</a>
           (<a id='7127' tid='7128' class='u'>let</a> ((<a id='7129' tid='7130' class='u'>,</a><a id='7131' tid='7132' class='u'>keys</a> (<a id='7133' tid='7134' class='u'>let</a> ((<a id='7135' tid='7136' class='u'>k</a> (<a id='7137' tid='7138' class='u'>car</a> <a id='7139' tid='7140' class='u'>,</a><a id='7141' tid='7142' class='u'>spec</a>)))
                          (<a id='7143' tid='7144' class='u'>cond</a> ((<a id='7145' tid='7146' class='u'>stringp</a> <a id='7147' tid='7148' class='u'>k</a>) (<a id='7149' tid='7150' class='u'>list</a> <a id='7151' tid='7152' class='u'>k</a>))
                                ((<a id='7153' tid='7154' class='u'>listp</a> <a id='7155' tid='7156' class='u'>k</a>) <a id='7157' tid='7158' class='u'>k</a>)
                                (<a id='7159' tid='7160' class='u'>t</a> (<a id='7161' tid='7162' class='u'>error</a> <a id='7163' tid='7164' class='u'>&quot;Invalid paredit command %s.&quot;</a>
                                          <a id='7165' tid='7166' class='u'>,</a><a id='7167' tid='7168' class='u'>spec</a>)))))
                 (<a id='7169' tid='7170' class='u'>,</a><a id='7171' tid='7172' class='u'>fn</a> (<a id='7173' tid='7174' class='u'>cadr</a> <a id='7175' tid='7176' class='u'>,</a><a id='7177' tid='7178' class='u'>spec</a>))
                 (<a id='7179' tid='7180' class='u'>,</a><a id='7181' tid='7182' class='u'>examples</a> (<a id='7183' tid='7184' class='u'>cddr</a> <a id='7185' tid='7186' class='u'>,</a><a id='7187' tid='7188' class='u'>spec</a>)))
             <a id='7189' tid='7190' class='u'>,</a><a id='7191' tid='7192' class='u'>@body</a>)))))

  (<a id='7193' tid='7194' class='u'>put</a> <a id='7195' tid='7196' class='u'>&#39;</a><a id='7197' tid='7198' class='u'>paredit-do-commands</a> <a id='7199' tid='7200' class='u'>&#39;</a><a id='7201' tid='7202' class='u'>lisp-indent-function</a> <a id='7203' tid='7204' class='u'>2</a>))

(<a id='2957' tid='2958' class='u'>defun</a> <a id='2959' tid='2960' class='u'>paredit-define-keys</a> ()
  (<a id='2961' tid='2962' class='u'>paredit-do-commands</a> (<a id='2963' tid='2964' class='u'>spec</a> <a id='2965' tid='2966' class='u'>keys</a> <a id='2967' tid='2968' class='u'>fn</a> <a id='2969' tid='2970' class='u'>examples</a>)
      <a id='2971' tid='2972' class='u'>nil</a>       <a id='2973' tid='2974' class='u'>; string case
</a>    (<a id='2975' tid='2976' class='u'>dolist</a> (<a id='2977' tid='2978' class='u'>key</a> <a id='2979' tid='2980' class='u'>keys</a>)
      (<a id='2981' tid='2982' class='u'>define-key</a> <a id='2983' tid='2984' class='u'>paredit-mode-map</a> (<a id='2985' tid='2986' class='u'>read-kbd-macro</a> <a id='2987' tid='2988' class='u'>key</a>) <a id='2989' tid='2990' class='u'>fn</a>))))

(<a id='3909' tid='3910' class='u'>defun</a> <a id='3911' tid='3912' class='u'>paredit-function-documentation</a> (<a id='3913' tid='3914' class='u'>fn</a>)
  (<a id='3915' tid='3916' class='u'>let</a> ((<a id='3917' tid='3918' class='u'>original-doc</a> (<a id='3919' tid='3920' class='u'>get</a> <a id='3921' tid='3922' class='u'>fn</a> <a id='3923' tid='3924' class='u'>&#39;</a><a id='3925' tid='3926' class='u'>paredit-original-documentation</a>))
        (<a id='3927' tid='3928' class='u'>doc</a> (<a id='3929' tid='3930' class='u'>documentation</a> <a id='3931' tid='3932' class='u'>fn</a> <a id='3933' tid='3934' class='u'>&#39;</a><a id='3935' tid='3936' class='u'>function-documentation</a>)))
    (<a id='3937' tid='3938' class='u'>or</a> <a id='3939' tid='3940' class='u'>original-doc</a>
        (<a id='3941' tid='3942' class='u'>progn</a> (<a id='3943' tid='3944' class='u'>put</a> <a id='3945' tid='3946' class='u'>fn</a> <a id='3947' tid='3948' class='u'>&#39;</a><a id='3949' tid='3950' class='u'>paredit-original-documentation</a> <a id='3951' tid='3952' class='u'>doc</a>)
               <a id='3953' tid='3954' class='u'>doc</a>))))

(<a id='1895' tid='1896' class='u'>defun</a> <a id='1897' tid='1898' class='u'>paredit-annotate-mode-with-examples</a> ()
  (<a id='1899' tid='1900' class='u'>let</a> ((<a id='1901' tid='1902' class='u'>contents</a>
         (<a id='1903' tid='1904' class='u'>list</a> (<a id='1905' tid='1906' class='u'>paredit-function-documentation</a> <a id='1907' tid='1908' class='u'>&#39;</a><a id='1909' tid='1910' class='u'>paredit-mode</a>))))
    (<a id='1911' tid='1912' class='u'>paredit-do-commands</a> (<a id='1913' tid='1914' class='u'>spec</a> <a id='1915' tid='1916' class='u'>keys</a> <a id='1917' tid='1918' class='u'>fn</a> <a id='1919' tid='1920' class='u'>examples</a>)
        (<a id='1921' tid='1922' class='u'>push</a> (<a id='1923' tid='1924' class='u'>concat</a> <a id='1925' tid='1926' class='u'>&quot;\n\n&quot;</a> <a id='1927' tid='1928' class='u'>spec</a> <a id='1929' tid='1930' class='u'>&quot;\n&quot;</a>)
              <a id='1931' tid='1932' class='u'>contents</a>)
      (<a id='1933' tid='1934' class='u'>let</a> ((<a id='1935' tid='1936' class='u'>name</a> (<a id='1937' tid='1938' class='u'>symbol-name</a> <a id='1939' tid='1940' class='u'>fn</a>)))
        (<a id='1941' tid='1942' class='u'>if</a> (<a id='1943' tid='1944' class='u'>string-match</a> (<a id='1945' tid='1946' class='u'>symbol-name</a> <a id='1947' tid='1948' class='u'>&#39;</a><a id='1949' tid='1950' class='u'>paredit-</a>) <a id='1951' tid='1952' class='u'>name</a>)
            (<a id='1953' tid='1954' class='u'>push</a> (<a id='1955' tid='1956' class='u'>concat</a> <a id='1957' tid='1958' class='u'>&quot;\n\n\\[&quot;</a> <a id='1959' tid='1960' class='u'>name</a> <a id='1961' tid='1962' class='u'>&quot;]\t&quot;</a> <a id='1963' tid='1964' class='u'>name</a>
                          (<a id='1965' tid='1966' class='u'>if</a> <a id='1967' tid='1968' class='u'>examples</a>
                              (<a id='1969' tid='1970' class='u'>mapconcat</a> (<a id='1971' tid='1972' class='u'>lambda</a> (<a id='1973' tid='1974' class='u'>example</a>)
                                           (<a id='1975' tid='1976' class='u'>concat</a>
                                            <a id='1977' tid='1978' class='u'>&quot;\n&quot;</a>
                                            (<a id='1979' tid='1980' class='u'>mapconcat</a> <a id='1981' tid='1982' class='u'>&#39;</a><a id='1983' tid='1984' class='u'>identity</a>
                                                       <a id='1985' tid='1986' class='u'>example</a>
                                                       <a id='1987' tid='1988' class='u'>&quot;\n  ---&gt;\n&quot;</a>)
                                            <a id='1989' tid='1990' class='u'>&quot;\n&quot;</a>))
                                         <a id='1991' tid='1992' class='u'>examples</a>
                                         <a id='1993' tid='1994' class='u'>&quot;&quot;</a>)
                              <a id='1995' tid='1996' class='u'>&quot;\n  (no examples)\n&quot;</a>))
                  <a id='1997' tid='1998' class='u'>contents</a>))))
    (<a id='1999' tid='2000' class='u'>put</a> <a id='2001' tid='2002' class='u'>&#39;</a><a id='2003' tid='2004' class='u'>paredit-mode</a> <a id='2005' tid='2006' class='u'>&#39;</a><a id='2007' tid='2008' class='u'>function-documentation</a>
         (<a id='2009' tid='2010' class='u'>apply</a> <a id='2011' tid='2012' class='u'>&#39;</a><a id='2013' tid='2014' class='u'>concat</a> (<a id='2015' tid='2016' class='u'>reverse</a> <a id='2017' tid='2018' class='u'>contents</a>))))
  <a id='2019' tid='2020' class='u'>;; PUT returns the huge string we just constructed, which we don&#39;t
</a>  <a id='2021' tid='2022' class='u'>;; want it to return.
</a>  <a id='2023' tid='2024' class='u'>nil</a>)

(<a id='1829' tid='1830' class='u'>defun</a> <a id='1831' tid='1832' class='u'>paredit-annotate-functions-with-examples</a> ()
  (<a id='1833' tid='1834' class='u'>paredit-do-commands</a> (<a id='1835' tid='1836' class='u'>spec</a> <a id='1837' tid='1838' class='u'>keys</a> <a id='1839' tid='1840' class='u'>fn</a> <a id='1841' tid='1842' class='u'>examples</a>)
      <a id='1843' tid='1844' class='u'>nil</a>       <a id='1845' tid='1846' class='u'>; string case
</a>    (<a id='1847' tid='1848' class='u'>put</a> <a id='1849' tid='1850' class='u'>fn</a> <a id='1851' tid='1852' class='u'>&#39;</a><a id='1853' tid='1854' class='u'>function-documentation</a>
         (<a id='1855' tid='1856' class='u'>concat</a> (<a id='1857' tid='1858' class='u'>paredit-function-documentation</a> <a id='1859' tid='1860' class='u'>fn</a>)
                 <a id='1861' tid='1862' class='u'>&quot;\n\n\\&lt;paredit-mode-map&gt;\\[&quot;</a> (<a id='1863' tid='1864' class='u'>symbol-name</a> <a id='1865' tid='1866' class='u'>fn</a>) <a id='1867' tid='1868' class='u'>&quot;]\n&quot;</a>
                 (<a id='1869' tid='1870' class='u'>mapconcat</a> (<a id='1871' tid='1872' class='u'>lambda</a> (<a id='1873' tid='1874' class='u'>example</a>)
                              (<a id='1875' tid='1876' class='u'>concat</a> <a id='1877' tid='1878' class='u'>&quot;\n&quot;</a>
                                      (<a id='1879' tid='1880' class='u'>mapconcat</a> <a id='1881' tid='1882' class='u'>&#39;</a><a id='1883' tid='1884' class='u'>identity</a>
                                                 <a id='1885' tid='1886' class='u'>example</a>
                                                 <a id='1887' tid='1888' class='u'>&quot;\n  -&gt;\n&quot;</a>)
                                      <a id='1889' tid='1890' class='u'>&quot;\n&quot;</a>))
                            <a id='1891' tid='1892' class='u'>examples</a>
                            <a id='1893' tid='1894' class='u'>&quot;&quot;</a>)))))

<a id='7205' tid='7206' class='u'>;;;;; HTML Examples
</a>
(<a id='4261' tid='4262' class='u'>defun</a> <a id='4263' tid='4264' class='u'>paredit-insert-html-examples</a> ()
  <a id='4265' tid='4266' class='u'>&quot;Insert HTML for a paredit quick reference table.&quot;</a>
  (<a id='4267' tid='4268' class='u'>interactive</a>)
  (<a id='4269' tid='4270' class='u'>let</a> ((<a id='4271' tid='4272' class='u'>insert-lines</a>
         (<a id='4273' tid='4274' class='u'>lambda</a> (<a id='4275' tid='4276' class='u'>&rest</a> <a id='4277' tid='4278' class='u'>lines</a>)
           (<a id='4279' tid='4280' class='u'>mapc</a> (<a id='4281' tid='4282' class='u'>lambda</a> (<a id='4283' tid='4284' class='u'>line</a>) (<a id='4285' tid='4286' class='u'>insert</a> <a id='4287' tid='4288' class='u'>line</a>) (<a id='4289' tid='4290' class='u'>newline</a>))
                 <a id='4291' tid='4292' class='u'>lines</a>)))
        (<a id='4293' tid='4294' class='u'>html-keys</a>
         (<a id='4295' tid='4296' class='u'>lambda</a> (<a id='4297' tid='4298' class='u'>keys</a>)
           (<a id='4299' tid='4300' class='u'>mapconcat</a> <a id='4301' tid='4302' class='u'>&#39;</a><a id='4303' tid='4304' class='u'>paredit-html-quote</a> <a id='4305' tid='4306' class='u'>keys</a> <a id='4307' tid='4308' class='u'>&quot;, &quot;</a>)))
        (<a id='4309' tid='4310' class='u'>html-example</a>
         (<a id='4311' tid='4312' class='u'>lambda</a> (<a id='4313' tid='4314' class='u'>example</a>)
           (<a id='4315' tid='4316' class='u'>concat</a> <a id='4317' tid='4318' class='u'>&quot;&lt;table&gt;&lt;tr&gt;&lt;td&gt;&lt;pre&gt;&quot;</a>
                   (<a id='4319' tid='4320' class='u'>mapconcat</a> <a id='4321' tid='4322' class='u'>&#39;</a><a id='4323' tid='4324' class='u'>paredit-html-quote</a>
                              <a id='4325' tid='4326' class='u'>example</a>
                              (<a id='4327' tid='4328' class='u'>concat</a> <a id='4329' tid='4330' class='u'>&quot;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&quot;</a>
                                      <a id='4331' tid='4332' class='u'>&quot;&nbsp;&nbsp;&nbsp;&nbsp;---&gt;&quot;</a>
                                      <a id='4333' tid='4334' class='u'>&quot;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;pre&gt;&quot;</a>))
                   <a id='4335' tid='4336' class='u'>&quot;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&quot;</a>)))
        (<a id='4337' tid='4338' class='u'>firstp</a> <a id='4339' tid='4340' class='u'>t</a>))
    (<a id='4341' tid='4342' class='u'>paredit-do-commands</a> (<a id='4343' tid='4344' class='u'>spec</a> <a id='4345' tid='4346' class='u'>keys</a> <a id='4347' tid='4348' class='u'>fn</a> <a id='4349' tid='4350' class='u'>examples</a>)
        (<a id='4351' tid='4352' class='u'>progn</a> (<a id='4353' tid='4354' class='u'>if</a> (<a id='4355' tid='4356' class='u'>not</a> <a id='4357' tid='4358' class='u'>firstp</a>)
                   (<a id='4359' tid='4360' class='u'>insert</a> <a id='4361' tid='4362' class='u'>&quot;&lt;/table&gt;\n&quot;</a>)
                   (<a id='4363' tid='4364' class='u'>setq</a> <a id='4365' tid='4366' class='u'>firstp</a> <a id='4367' tid='4368' class='u'>nil</a>))
               (<a id='4369' tid='4370' class='u'>funcall</a> <a id='4371' tid='4372' class='u'>insert-lines</a>
                        (<a id='4373' tid='4374' class='u'>concat</a> <a id='4375' tid='4376' class='u'>&quot;&lt;h3&gt;&quot;</a> <a id='4377' tid='4378' class='u'>spec</a> <a id='4379' tid='4380' class='u'>&quot;&lt;/h3&gt;&quot;</a>)
                        <a id='4381' tid='4382' class='u'>&quot;&lt;table border=\&quot;1\&quot; cellpadding=\&quot;1\&quot;&gt;&quot;</a>
                        <a id='4383' tid='4384' class='u'>&quot;  &lt;tr&gt;&quot;</a>
                        <a id='4385' tid='4386' class='u'>&quot;    &lt;th&gt;Command&lt;/th&gt;&quot;</a>
                        <a id='4387' tid='4388' class='u'>&quot;    &lt;th&gt;Keys&lt;/th&gt;&quot;</a>
                        <a id='4389' tid='4390' class='u'>&quot;    &lt;th&gt;Examples&lt;/th&gt;&quot;</a>
                        <a id='4391' tid='4392' class='u'>&quot;  &lt;/tr&gt;&quot;</a>))
      (<a id='4393' tid='4394' class='u'>let</a> ((<a id='4395' tid='4396' class='u'>name</a> (<a id='4397' tid='4398' class='u'>symbol-name</a> <a id='4399' tid='4400' class='u'>fn</a>)))
        (<a id='4401' tid='4402' class='u'>if</a> (<a id='4403' tid='4404' class='u'>string-match</a> (<a id='4405' tid='4406' class='u'>symbol-name</a> <a id='4407' tid='4408' class='u'>&#39;</a><a id='4409' tid='4410' class='u'>paredit-</a>) <a id='4411' tid='4412' class='u'>name</a>)
            (<a id='4413' tid='4414' class='u'>funcall</a> <a id='4415' tid='4416' class='u'>insert-lines</a>
                     <a id='4417' tid='4418' class='u'>&quot;  &lt;tr&gt;&quot;</a>
                     (<a id='4419' tid='4420' class='u'>concat</a> <a id='4421' tid='4422' class='u'>&quot;    &lt;td&gt;&lt;tt&gt;&quot;</a> <a id='4423' tid='4424' class='u'>name</a> <a id='4425' tid='4426' class='u'>&quot;&lt;/tt&gt;&lt;/td&gt;&quot;</a>)
                     (<a id='4427' tid='4428' class='u'>concat</a> <a id='4429' tid='4430' class='u'>&quot;    &lt;td align=\&quot;center\&quot;&gt;&quot;</a>
                             (<a id='4431' tid='4432' class='u'>funcall</a> <a id='4433' tid='4434' class='u'>html-keys</a> <a id='4435' tid='4436' class='u'>keys</a>)
                             <a id='4437' tid='4438' class='u'>&quot;&lt;/td&gt;&quot;</a>)
                     (<a id='4439' tid='4440' class='u'>concat</a> <a id='4441' tid='4442' class='u'>&quot;    &lt;td&gt;&quot;</a>
                             (<a id='4443' tid='4444' class='u'>if</a> <a id='4445' tid='4446' class='u'>examples</a>
                                 (<a id='4447' tid='4448' class='u'>mapconcat</a> <a id='4449' tid='4450' class='u'>html-example</a> <a id='4451' tid='4452' class='u'>examples</a>
                                            <a id='4453' tid='4454' class='u'>&quot;&lt;hr&gt;&quot;</a>)
                                 <a id='4455' tid='4456' class='u'>&quot;(no examples)&quot;</a>)
                             <a id='4457' tid='4458' class='u'>&quot;&lt;/td&gt;&quot;</a>)
                     <a id='4459' tid='4460' class='u'>&quot;  &lt;/tr&gt;&quot;</a>)))))
  (<a id='4461' tid='4462' class='u'>insert</a> <a id='4463' tid='4464' class='u'>&quot;&lt;/table&gt;\n&quot;</a>))

(<a id='3997' tid='3998' class='u'>defun</a> <a id='3999' tid='4000' class='u'>paredit-html-quote</a> (<a id='4001' tid='4002' class='u'>string</a>)
  (<a id='4003' tid='4004' class='u'>with-temp-buffer</a>
    (<a id='4005' tid='4006' class='u'>dotimes</a> (<a id='4007' tid='4008' class='u'>i</a> (<a id='4009' tid='4010' class='u'>length</a> <a id='4011' tid='4012' class='u'>string</a>))
      (<a id='4013' tid='4014' class='u'>insert</a> (<a id='4015' tid='4016' class='u'>let</a> ((<a id='4017' tid='4018' class='u'>c</a> (<a id='4019' tid='4020' class='u'>elt</a> <a id='4021' tid='4022' class='u'>string</a> <a id='4023' tid='4024' class='u'>i</a>)))
                (<a id='4025' tid='4026' class='u'>cond</a> ((<a id='4027' tid='4028' class='u'>eq</a> <a id='4029' tid='4030' class='u'>c</a> <a id='4031' tid='4032' class='u'>?\&lt;</a>) <a id='4033' tid='4034' class='u'>&quot;&lt;&quot;</a>)
                      ((<a id='4035' tid='4036' class='u'>eq</a> <a id='4037' tid='4038' class='u'>c</a> <a id='4039' tid='4040' class='u'>?\&gt;</a>) <a id='4041' tid='4042' class='u'>&quot;&gt;&quot;</a>)
                      ((<a id='4043' tid='4044' class='u'>eq</a> <a id='4045' tid='4046' class='u'>c</a> <a id='4047' tid='4048' class='u'>?\&</a>) <a id='4049' tid='4050' class='u'>&quot;&amp;&quot;</a>)
                      ((<a id='4051' tid='4052' class='u'>eq</a> <a id='4053' tid='4054' class='u'>c</a> <a id='4055' tid='4056' class='u'>?\&#39;</a>) <a id='4057' tid='4058' class='u'>&quot;&apos;&quot;</a>)
                      ((<a id='4059' tid='4060' class='u'>eq</a> <a id='4061' tid='4062' class='u'>c</a> <a id='4063' tid='4064' class='u'>?\&quot;</a>) <a id='4065' tid='4066' class='u'>&quot;&quot;&quot;</a>)
                      (<a id='4067' tid='4068' class='u'>t</a> <a id='4069' tid='4070' class='u'>c</a>)))))
    (<a id='4071' tid='4072' class='u'>buffer-string</a>)))

<a id='7207' tid='7208' class='u'>;;;; Delimiter Insertion
</a>
(<a id='783' tid='784' class='m'>eval-and-compile</a>
  (<a id='765' tid='766' class='m'>defun</a> <a id='767' tid='768' class='m'>paredit-conc-name</a> (<a id='769' tid='770' class='m'>&rest</a> <a id='771' tid='772' class='m'>strings</a>)
    (<a id='773' tid='774' class='m'>intern</a> (<a id='775' tid='776' class='m'>apply</a> <a id='777' tid='778' class='m'>&#39;</a><a id='779' tid='780' class='m'>concat</a> <a id='781' tid='782' class='m'>strings</a>)))

  (<a id='785' tid='786' class='m'>defmacro</a> <a id='787' tid='788' class='m'>define-paredit-pair</a> (<a id='789' tid='790' class='m'>open</a> <a id='791' tid='792' class='m'>close</a> <a id='793' tid='794' class='m'>name</a>)
    <a id='795' tid='796' class='m'>`</a>(<a id='959' tid='960' class='m'>progn</a>
       (<a id='797' tid='798' class='m'>defun</a> <a id='799' tid='800' class='m'>,</a>(<a id='801' tid='802' class='m'>paredit-conc-name</a> <a id='803' tid='804' class='m'>&quot;paredit-open-&quot;</a> <a id='805' tid='806' class='m'>name</a>) (<a id='807' tid='808' class='m'>&optional</a> <a id='809' tid='810' class='m'>n</a>)
         <a id='811' tid='812' class='m'>,</a>(<a id='813' tid='814' class='m'>concat</a> <a id='815' tid='816' class='m'>&quot;Insert a balanced &quot;</a> <a id='817' tid='818' class='m'>name</a> <a id='819' tid='820' class='m'>&quot; pair.
With a prefix argument N, put the closing &quot;</a> <a id='821' tid='822' class='m'>name</a> <a id='823' tid='824' class='m'>&quot; after N
  S-expressions forward.
If the region is active, `transient-mark-mode&#39; is enabled, and the
  region&#39;s start and end fall in the same parenthesis depth, insert a
  &quot;</a> <a id='825' tid='826' class='m'>name</a> <a id='827' tid='828' class='m'>&quot; pair around the region.
If in a string or a comment, insert a single &quot;</a> <a id='829' tid='830' class='m'>name</a> <a id='831' tid='832' class='m'>&quot;.
If in a character literal, do nothing.  This prevents changing what was
  in the character literal to a meaningful delimiter unintentionally.&quot;</a>)
         (<a id='833' tid='834' class='m'>interactive</a> <a id='835' tid='836' class='m'>&quot;P&quot;</a>)
         (<a id='837' tid='838' class='m'>cond</a> ((<a id='839' tid='840' class='m'>or</a> (<a id='841' tid='842' class='m'>paredit-in-string-p</a>)
                    (<a id='843' tid='844' class='m'>paredit-in-comment-p</a>))
                (<a id='845' tid='846' class='m'>insert</a> <a id='847' tid='848' class='m'>,</a><a id='849' tid='850' class='m'>open</a>))
               (<span class='d'>(not (paredit-in-char-p))</span>
                (<a id='851' tid='852' class='m'>paredit-insert-pair</a> <a id='853' tid='854' class='m'>n</a> <a id='855' tid='856' class='m'>,</a><a id='857' tid='858' class='m'>open</a> <a id='859' tid='860' class='m'>,</a><a id='861' tid='862' class='m'>close</a> <a id='863' tid='864' class='m'>&#39;</a><a id='865' tid='866' class='m'>goto-char</a>))))
       (<a id='867' tid='868' class='m'>defun</a> <a id='869' tid='870' class='m'>,</a>(<a id='871' tid='872' class='m'>paredit-conc-name</a> <a id='873' tid='874' class='m'>&quot;paredit-close-&quot;</a> <a id='875' tid='876' class='m'>name</a>) ()
         <a id='877' tid='878' class='m'>,</a>(<a id='879' tid='880' class='m'>concat</a> <a id='881' tid='882' class='m'>&quot;Move past one closing delimiter and reindent.
\(Agnostic to the specific closing delimiter.)
If in a string or comment, insert a single closing &quot;</a> <a id='883' tid='884' class='m'>name</a> <a id='885' tid='886' class='m'>&quot;.
If in a character literal, do nothing.  This prevents changing what was
  in the character literal to a meaningful delimiter unintentionally.&quot;</a>)
         (<a id='887' tid='888' class='m'>interactive</a>)
         (<a id='889' tid='890' class='m'>paredit-move-past-close</a> <a id='891' tid='892' class='m'>,</a><a id='893' tid='894' class='m'>close</a>))
       (<a id='895' tid='896' class='m'>defun</a> <a id='897' tid='898' class='m'>,</a>(<a id='899' tid='900' class='m'>paredit-conc-name</a> <a id='901' tid='902' class='m'>&quot;paredit-close-&quot;</a> <a id='903' tid='904' class='m'>name</a> <a id='905' tid='906' class='m'>&quot;-and-newline&quot;</a>) ()
         <a id='907' tid='908' class='m'>,</a>(<a id='909' tid='910' class='m'>concat</a> <a id='911' tid='912' class='m'>&quot;Move past one closing delimiter, add a newline,&quot;</a>
                  <a id='913' tid='914' class='m'>&quot; and reindent.
If there was a margin comment after the closing delimiter, preserve it
  on the same line.&quot;</a>)
         (<a id='915' tid='916' class='m'>interactive</a>)
         (<a id='917' tid='918' class='m'>paredit-move-past-close-and-newline</a> <a id='919' tid='920' class='m'>,</a><a id='921' tid='922' class='m'>close</a>))
       (<a id='923' tid='924' class='m'>defun</a> <a id='925' tid='926' class='m'>,</a>(<a id='927' tid='928' class='m'>paredit-conc-name</a> <a id='929' tid='930' class='m'>&quot;paredit-wrap-&quot;</a> <a id='931' tid='932' class='m'>name</a>)
           (<a id='933' tid='934' class='m'>&optional</a> <a id='935' tid='936' class='m'>argument</a>)
         <a id='937' tid='938' class='m'>,</a>(<a id='939' tid='940' class='m'>concat</a> <a id='941' tid='942' class='m'>&quot;Wrap the following S-expression.
See `paredit-wrap-sexp&#39; for more details.&quot;</a>)
         (<a id='943' tid='944' class='m'>interactive</a> <a id='945' tid='946' class='m'>&quot;P&quot;</a>)
         (<a id='947' tid='948' class='m'>paredit-wrap-sexp</a> <a id='949' tid='950' class='m'>argument</a> <a id='951' tid='952' class='m'>,</a><a id='953' tid='954' class='m'>open</a> <a id='955' tid='956' class='m'>,</a><a id='957' tid='958' class='m'>close</a>))
       (<a id='961' tid='962' class='m'>add-to-list</a> <a id='963' tid='964' class='m'>&#39;</a><a id='965' tid='966' class='m'>paredit-wrap-commands</a>
                    <a id='967' tid='968' class='m'>&#39;</a><a id='969' tid='970' class='m'>,</a>(<a id='971' tid='972' class='m'>paredit-conc-name</a> <a id='973' tid='974' class='m'>&quot;paredit-wrap-&quot;</a> <a id='975' tid='976' class='m'>name</a>)))))

(<a id='6537' tid='6538' class='u'>defvar</a> <a id='6539' tid='6540' class='u'>paredit-wrap-commands</a> <a id='6541' tid='6542' class='u'>&#39;</a>(<a id='6543' tid='6544' class='u'>paredit-wrap-sexp</a>)
  <a id='6545' tid='6546' class='u'>&quot;List of paredit commands that wrap S-expressions.
Used by `paredit-yank-pop&#39;; for internal paredit use only.&quot;</a>)

(<a id='7209' tid='7210' class='u'>define-paredit-pair</a> <a id='7211' tid='7212' class='u'>?\(</a> <a id='7213' tid='7214' class='u'>?\)</a> <a id='7215' tid='7216' class='u'>&quot;round&quot;</a>)
(<a id='7217' tid='7218' class='u'>define-paredit-pair</a> <a id='7219' tid='7220' class='u'>?\[</a> <a id='7221' tid='7222' class='u'>?\]</a> <a id='7223' tid='7224' class='u'>&quot;square&quot;</a>)
(<a id='7225' tid='7226' class='u'>define-paredit-pair</a> <a id='7227' tid='7228' class='u'>?\{</a> <a id='7229' tid='7230' class='u'>?\}</a> <a id='7231' tid='7232' class='u'>&quot;curly&quot;</a>)
(<a id='7233' tid='7234' class='u'>define-paredit-pair</a> <a id='7235' tid='7236' class='u'>?\&lt;</a> <a id='7237' tid='7238' class='u'>?\&gt;</a> <a id='7239' tid='7240' class='u'>&quot;angled&quot;</a>)

<a id='7241' tid='7242' class='u'>;;; Aliases for the old names.
</a>
(<a id='7243' tid='7244' class='u'>defalias</a> <a id='7245' tid='7246' class='u'>&#39;</a><a id='7247' tid='7248' class='u'>paredit-open-parenthesis</a> <a id='7249' tid='7250' class='u'>&#39;</a><a id='7251' tid='7252' class='u'>paredit-open-round</a>)
(<a id='7253' tid='7254' class='u'>defalias</a> <a id='7255' tid='7256' class='u'>&#39;</a><a id='7257' tid='7258' class='u'>paredit-close-parenthesis</a> <a id='7259' tid='7260' class='u'>&#39;</a><a id='7261' tid='7262' class='u'>paredit-close-round</a>)
(<a id='7263' tid='7264' class='u'>defalias</a> <a id='7265' tid='7266' class='u'>&#39;</a><a id='7267' tid='7268' class='u'>paredit-close-parenthesis-and-newline</a>
  <a id='7269' tid='7270' class='u'>&#39;</a><a id='7271' tid='7272' class='u'>paredit-close-round-and-newline</a>)

(<a id='7273' tid='7274' class='u'>defalias</a> <a id='7275' tid='7276' class='u'>&#39;</a><a id='7277' tid='7278' class='u'>paredit-open-bracket</a> <a id='7279' tid='7280' class='u'>&#39;</a><a id='7281' tid='7282' class='u'>paredit-open-square</a>)
(<a id='7283' tid='7284' class='u'>defalias</a> <a id='7285' tid='7286' class='u'>&#39;</a><a id='7287' tid='7288' class='u'>paredit-close-bracket</a> <a id='7289' tid='7290' class='u'>&#39;</a><a id='7291' tid='7292' class='u'>paredit-close-square</a>)
(<a id='7293' tid='7294' class='u'>defalias</a> <a id='7295' tid='7296' class='u'>&#39;</a><a id='7297' tid='7298' class='u'>paredit-close-bracket-and-newline</a>
  <a id='7299' tid='7300' class='u'>&#39;</a><a id='7301' tid='7302' class='u'>paredit-close-square-and-newline</a>)

(<a id='5309' tid='5310' class='u'>defun</a> <a id='5311' tid='5312' class='u'>paredit-move-past-close</a> (<a id='5313' tid='5314' class='u'>close</a>)
  <span class='d'>(cond ((or (paredit-in-string-p)
             (paredit-in-comment-p))
         (insert close))
        ((not (paredit-in-char-p))
         (paredit-move-past-close-and-reindent close)
         (paredit-blink-paren-match nil)))</span>)

(<a id='5315' tid='5316' class='u'>defun</a> <a id='5317' tid='5318' class='u'>paredit-move-past-close-and-newline</a> (<a id='5319' tid='5320' class='u'>close</a>)
  (<span class='d'>if</span> <span class='d'>(or (paredit-in-string-p)
          (paredit-in-comment-p))</span>
      <span class='d'>(insert close)</span>
    <span class='d'>(if (paredit-in-char-p) (forward-char))</span>
    <span class='d'>(paredit-move-past-close-and-reindent close)</span>
    (<a id='977' tid='978' class='m'>let</a> ((<a id='979' tid='980' class='m'>comment.point</a> (<a id='981' tid='982' class='m'>paredit-find-comment-on-line</a>)))
      (<a id='983' tid='984' class='m'>newline</a>)
      (<a id='985' tid='986' class='m'>if</a> <a id='987' tid='988' class='m'>comment.point</a>
          (<a id='989' tid='990' class='m'>save-excursion</a>
            (<a id='991' tid='992' class='m'>forward-line</a> <a id='993' tid='994' class='m'>-1</a>)
            (<a id='995' tid='996' class='m'>end-of-line</a>)
            (<a id='997' tid='998' class='m'>indent-to</a> (<a id='999' tid='1000' class='m'>cdr</a> <a id='1001' tid='1002' class='m'>comment.point</a>))
            (<a id='1003' tid='1004' class='m'>insert</a> (<a id='1005' tid='1006' class='m'>car</a> <a id='1007' tid='1008' class='m'>comment.point</a>)))))
    <span class='d'>(lisp-indent-line)</span>
    <span class='d'>(paredit-ignore-sexp-errors (indent-sexp))</span>
    <span class='d'>(paredit-blink-paren-match t)</span>))

(<a id='3105' tid='3106' class='u'>defun</a> <a id='3107' tid='3108' class='u'>paredit-find-comment-on-line</a> ()
  <a id='3109' tid='3110' class='u'>&quot;Find a margin comment on the current line.
Return nil if there is no such comment or if there is anything but
  whitespace until such a comment.
If such a comment exists, delete the comment (including all leading
  whitespace) and return a cons whose car is the comment as a string
  and whose cdr is the point of the comment&#39;s initial semicolon,
  relative to the start of the line.&quot;</a>
  (<a id='3111' tid='3112' class='u'>save-excursion</a>
    (<a id='3113' tid='3114' class='u'>paredit-skip-whitespace</a> <a id='3115' tid='3116' class='u'>t</a> (<a id='3117' tid='3118' class='u'>point-at-eol</a>))
    (<a id='3119' tid='3120' class='u'>and</a> (<a id='3121' tid='3122' class='u'>eq</a> <a id='3123' tid='3124' class='u'>?\;</a> (<a id='3125' tid='3126' class='u'>char-after</a>))
         (<a id='3127' tid='3128' class='u'>not</a> (<a id='3129' tid='3130' class='u'>eq</a> <a id='3131' tid='3132' class='u'>?\;</a> (<a id='3133' tid='3134' class='u'>char-after</a> (<a id='3135' tid='3136' class='u'>1+</a> (<a id='3137' tid='3138' class='u'>point</a>)))))
         (<a id='3139' tid='3140' class='u'>not</a> (<a id='3141' tid='3142' class='u'>or</a> (<a id='3143' tid='3144' class='u'>paredit-in-string-p</a>)
                  (<a id='3145' tid='3146' class='u'>paredit-in-char-p</a>)))
         (<a id='3147' tid='3148' class='u'>let*</a> ((<a id='3149' tid='3150' class='u'>start</a>                  <a id='3151' tid='3152' class='u'>;Move to before the semicolon.
</a>                 (<a id='3153' tid='3154' class='u'>progn</a> (<a id='3155' tid='3156' class='u'>backward-char</a>) (<a id='3157' tid='3158' class='u'>point</a>)))
                (<a id='3159' tid='3160' class='u'>comment</a>
                 (<a id='3161' tid='3162' class='u'>buffer-substring</a> <a id='3163' tid='3164' class='u'>start</a> (<a id='3165' tid='3166' class='u'>point-at-eol</a>))))
           (<a id='3167' tid='3168' class='u'>paredit-skip-whitespace</a> <a id='3169' tid='3170' class='u'>nil</a> (<a id='3171' tid='3172' class='u'>point-at-bol</a>))
           (<a id='3173' tid='3174' class='u'>delete-region</a> (<a id='3175' tid='3176' class='u'>point</a>) (<a id='3177' tid='3178' class='u'>point-at-eol</a>))
           (<a id='3179' tid='3180' class='u'>cons</a> <a id='3181' tid='3182' class='u'>comment</a> (<a id='3183' tid='3184' class='u'>-</a> <a id='3185' tid='3186' class='u'>start</a> (<a id='3187' tid='3188' class='u'>point-at-bol</a>)))))))

(<a id='4465' tid='4466' class='u'>defun</a> <a id='4467' tid='4468' class='u'>paredit-insert-pair</a> (<a id='4469' tid='4470' class='u'>n</a> <a id='4471' tid='4472' class='u'>open</a> <a id='4473' tid='4474' class='u'>close</a> <a id='4475' tid='4476' class='u'>forward</a>)
  (<a id='1009' tid='1010' class='m'>let*</a> ((<a id='1011' tid='1012' class='m'>regionp</a>
          (<a id='1013' tid='1014' class='m'>and</a> (<a id='1015' tid='1016' class='m'>paredit-region-active-p</a>)
               (<a id='1017' tid='1018' class='m'>paredit-region-safe-for-insert-p</a>)))
         (<a id='1019' tid='1020' class='m'>end</a>
          (<a id='1021' tid='1022' class='m'>and</a> <a id='1023' tid='1024' class='m'>regionp</a>
               (<a id='1025' tid='1026' class='m'>not</a> <a id='1027' tid='1028' class='m'>n</a>)
               (<a id='1029' tid='1030' class='m'>prog1</a> (<a id='1031' tid='1032' class='m'>region-end</a>) (<a id='1033' tid='1034' class='m'>goto-char</a> (<a id='1035' tid='1036' class='m'>region-beginning</a>))))))
    (<a id='1037' tid='1038' class='m'>let</a> ((<a id='1039' tid='1040' class='m'>spacep</a> (<a id='1041' tid='1042' class='m'>paredit-space-for-delimiter-p</a> <a id='1043' tid='1044' class='m'>nil</a> <a id='1045' tid='1046' class='m'>open</a>)))
      (<a id='1047' tid='1048' class='m'>if</a> <a id='1049' tid='1050' class='m'>spacep</a> (<a id='1051' tid='1052' class='m'>insert</a> <a id='1053' tid='1054' class='m'>&quot; &quot;</a>))
      (<a id='1055' tid='1056' class='m'>insert</a> <a id='1057' tid='1058' class='m'>open</a>)
      (<span class='d'>save-excursion</span>
        <span class='d'>;; Move past the desired region.
</span>        (<span class='d'>cond</span> <span class='d'>(n (funcall forward
                          (save-excursion
                            (forward-sexp (prefix-numeric-value n))
                            (point))))</span>
              (<a id='1059' tid='1060' class='m'>regionp</a> (<a id='1061' tid='1062' class='m'>funcall</a> <a id='1063' tid='1064' class='m'>forward</a> (<a id='1065' tid='1066' class='m'>+</a> <a id='1067' tid='1068' class='m'>end</a> (<a id='1069' tid='1070' class='m'>if</a> <a id='1071' tid='1072' class='m'>spacep</a> <a id='1073' tid='1074' class='m'>2</a> <a id='1075' tid='1076' class='m'>1</a>)))))
        <span class='d'>(insert close)</span>
        (<a id='537' tid='538' class='m'>if</a> (<a id='539' tid='540' class='m'>paredit-space-for-delimiter-p</a> <a id='541' tid='542' class='m'>t</a> <a id='543' tid='544' class='m'>close</a>)
            (<a id='545' tid='546' class='m'>insert</a> <a id='547' tid='548' class='m'>&quot; &quot;</a>))))))

(<a id='5729' tid='5730' class='u'>defun</a> <a id='5731' tid='5732' class='u'>paredit-region-safe-for-insert-p</a> ()
  (<a id='5733' tid='5734' class='u'>save-excursion</a>
    (<a id='5735' tid='5736' class='u'>let</a> ((<a id='5737' tid='5738' class='u'>beginning</a> (<a id='5739' tid='5740' class='u'>region-beginning</a>))
          (<a id='5741' tid='5742' class='u'>end</a> (<a id='5743' tid='5744' class='u'>region-end</a>)))
      (<a id='5745' tid='5746' class='u'>goto-char</a> <a id='5747' tid='5748' class='u'>beginning</a>)
      (<a id='5749' tid='5750' class='u'>let*</a> ((<a id='5751' tid='5752' class='u'>beginning-state</a> (<a id='5753' tid='5754' class='u'>paredit-current-parse-state</a>))
             (<a id='5755' tid='5756' class='u'>end-state</a>
              (<a id='5757' tid='5758' class='u'>parse-partial-sexp</a> <a id='5759' tid='5760' class='u'>beginning</a> <a id='5761' tid='5762' class='u'>end</a> <a id='5763' tid='5764' class='u'>nil</a> <a id='5765' tid='5766' class='u'>nil</a> <a id='5767' tid='5768' class='u'>beginning-state</a>)))
        (<a id='5769' tid='5770' class='u'>and</a> (<a id='5771' tid='5772' class='u'>=</a>  (<a id='5773' tid='5774' class='u'>nth</a> <a id='5775' tid='5776' class='u'>0</a> <a id='5777' tid='5778' class='u'>beginning-state</a>)   <a id='5779' tid='5780' class='u'>; 0. depth in parens
</a>                 (<a id='5781' tid='5782' class='u'>nth</a> <a id='5783' tid='5784' class='u'>0</a> <a id='5785' tid='5786' class='u'>end-state</a>))
             (<a id='5787' tid='5788' class='u'>eq</a> (<a id='5789' tid='5790' class='u'>nth</a> <a id='5791' tid='5792' class='u'>3</a> <a id='5793' tid='5794' class='u'>beginning-state</a>)   <a id='5795' tid='5796' class='u'>; 3. non-nil if inside a
</a>                 (<a id='5797' tid='5798' class='u'>nth</a> <a id='5799' tid='5800' class='u'>3</a> <a id='5801' tid='5802' class='u'>end-state</a>))        <a id='5803' tid='5804' class='u'>;    string
</a>             (<a id='5805' tid='5806' class='u'>eq</a> (<a id='5807' tid='5808' class='u'>nth</a> <a id='5809' tid='5810' class='u'>4</a> <a id='5811' tid='5812' class='u'>beginning-state</a>)   <a id='5813' tid='5814' class='u'>; 4. comment status, yada
</a>                 (<a id='5815' tid='5816' class='u'>nth</a> <a id='5817' tid='5818' class='u'>4</a> <a id='5819' tid='5820' class='u'>end-state</a>))
             (<a id='5821' tid='5822' class='u'>eq</a> (<a id='5823' tid='5824' class='u'>nth</a> <a id='5825' tid='5826' class='u'>5</a> <a id='5827' tid='5828' class='u'>beginning-state</a>)   <a id='5829' tid='5830' class='u'>; 5. t if following char
</a>                 (<a id='5831' tid='5832' class='u'>nth</a> <a id='5833' tid='5834' class='u'>5</a> <a id='5835' tid='5836' class='u'>end-state</a>)))))))   <span class='d'>;    quote
</span>
(<a id='6141' tid='6142' class='u'>defvar</a> <a id='6143' tid='6144' class='u'>paredit-space-for-delimiter-predicates</a> <a id='6145' tid='6146' class='u'>nil</a>
  <a id='6147' tid='6148' class='u'>&quot;List of predicates for whether to put space by delimiter at point.
Each predicate is a function that is is applied to two arguments, ENDP
  and DELIMITER, and that returns a boolean saying whether to put a
  space next to the delimiter -- before the delimiter if ENDP is false,
  after the delimiter if ENDP is true.
If any predicate returns false, no space is inserted: every predicate
  has veto power.
Each predicate may assume that the point is not at the beginning of the
  buffer, if ENDP is false, or at the end of the buffer, if ENDP is
  true; and that the point is not preceded, if ENDP is false, or
  followed, if ENDP is true, by a word or symbol constituent, a quote,
  or the delimiter matching DELIMITER.
Each predicate should examine only text before the point, if ENDP is
  false, or only text after the point, if ENDP is true.&quot;</a>)

(<a id='6027' tid='6028' class='u'>defun</a> <a id='6029' tid='6030' class='u'>paredit-space-for-delimiter-p</a> (<a id='6031' tid='6032' class='u'>endp</a> <a id='6033' tid='6034' class='u'>delimiter</a>)
  <a id='6035' tid='6036' class='u'>;; If at the buffer limit, don&#39;t insert a space.  If there is a word,
</a>  <a id='6037' tid='6038' class='u'>;; symbol, other quote, or non-matching parenthesis delimiter (i.e. a
</a>  <a id='6039' tid='6040' class='u'>;; close when want an open the string or an open when we want to
</a>  <a id='6041' tid='6042' class='u'>;; close the string), do insert a space.
</a>  (<a id='6043' tid='6044' class='u'>and</a> (<a id='6045' tid='6046' class='u'>not</a> (<a id='6047' tid='6048' class='u'>if</a> <a id='6049' tid='6050' class='u'>endp</a> (<a id='6051' tid='6052' class='u'>eobp</a>) (<a id='6053' tid='6054' class='u'>bobp</a>)))
       (<a id='6055' tid='6056' class='u'>memq</a> (<a id='6057' tid='6058' class='u'>char-syntax</a> (<a id='6059' tid='6060' class='u'>if</a> <a id='6061' tid='6062' class='u'>endp</a> (<a id='6063' tid='6064' class='u'>char-after</a>) (<a id='6065' tid='6066' class='u'>char-before</a>)))
             (<a id='6067' tid='6068' class='u'>list</a> <a id='6069' tid='6070' class='u'>?w</a> <a id='6071' tid='6072' class='u'>?_</a> <a id='6073' tid='6074' class='u'>?\&quot;</a>
                   (<a id='6075' tid='6076' class='u'>let</a> ((<a id='6077' tid='6078' class='u'>matching</a> (<a id='6079' tid='6080' class='u'>matching-paren</a> <a id='6081' tid='6082' class='u'>delimiter</a>)))
                     (<a id='6083' tid='6084' class='u'>and</a> <a id='6085' tid='6086' class='u'>matching</a> (<a id='6087' tid='6088' class='u'>char-syntax</a> <a id='6089' tid='6090' class='u'>matching</a>)))
                   (<a id='6091' tid='6092' class='u'>and</a> (<a id='6093' tid='6094' class='u'>not</a> <a id='6095' tid='6096' class='u'>endp</a>)
                        (<a id='6097' tid='6098' class='u'>eq</a> <a id='6099' tid='6100' class='u'>?\&quot;</a> (<a id='6101' tid='6102' class='u'>char-syntax</a> <a id='6103' tid='6104' class='u'>delimiter</a>))
                        <a id='6105' tid='6106' class='u'>?\)</a> )))
       (<a id='6107' tid='6108' class='u'>catch</a> <a id='6109' tid='6110' class='u'>&#39;</a><a id='6111' tid='6112' class='u'>exit</a>
         (<a id='6113' tid='6114' class='u'>dolist</a> (<a id='6115' tid='6116' class='u'>predicate</a> <a id='6117' tid='6118' class='u'>paredit-space-for-delimiter-predicates</a>)
           (<a id='6119' tid='6120' class='u'>if</a> (<a id='6121' tid='6122' class='u'>not</a> (<a id='6123' tid='6124' class='u'>funcall</a> <a id='6125' tid='6126' class='u'>predicate</a> <a id='6127' tid='6128' class='u'>endp</a> <a id='6129' tid='6130' class='u'>delimiter</a>))
               (<a id='6131' tid='6132' class='u'>throw</a> <a id='6133' tid='6134' class='u'>&#39;</a><a id='6135' tid='6136' class='u'>exit</a> <a id='6137' tid='6138' class='u'>nil</a>)))
         <a id='6139' tid='6140' class='u'>t</a>)))

(<a id='5321' tid='5322' class='u'>defun</a> <a id='5323' tid='5324' class='u'>paredit-move-past-close-and-reindent</a> (<a id='5325' tid='5326' class='u'>close</a>)
  (<a id='5327' tid='5328' class='u'>let</a> ((<a id='5329' tid='5330' class='u'>open</a> (<a id='5331' tid='5332' class='u'>paredit-missing-close</a>)))
    (<a id='5333' tid='5334' class='u'>if</a> <a id='5335' tid='5336' class='u'>open</a>
        (<a id='5337' tid='5338' class='u'>if</a> (<a id='5339' tid='5340' class='u'>eq</a> <a id='5341' tid='5342' class='u'>close</a> (<a id='5343' tid='5344' class='u'>matching-paren</a> <a id='5345' tid='5346' class='u'>open</a>))
            (<a id='5347' tid='5348' class='u'>save-excursion</a>
              (<a id='5349' tid='5350' class='u'>message</a> <a id='5351' tid='5352' class='u'>&quot;Missing closing delimiter: %c&quot;</a> <a id='5353' tid='5354' class='u'>close</a>)
              (<a id='5355' tid='5356' class='u'>insert</a> <a id='5357' tid='5358' class='u'>close</a>))
            (<a id='5359' tid='5360' class='u'>error</a> <a id='5361' tid='5362' class='u'>&quot;Mismatched missing closing delimiter: %c ... %c&quot;</a>
                   <a id='5363' tid='5364' class='u'>open</a> <a id='5365' tid='5366' class='u'>close</a>))))
  (<a id='5367' tid='5368' class='u'>up-list</a>)
  (<a id='5369' tid='5370' class='u'>if</a> (<a id='5371' tid='5372' class='u'>catch</a> <a id='5373' tid='5374' class='u'>&#39;</a><a id='5375' tid='5376' class='u'>return</a>                    <a id='5377' tid='5378' class='u'>; This CATCH returns T if it
</a>        (<a id='5379' tid='5380' class='u'>while</a> <a id='5381' tid='5382' class='u'>t</a>                        <a id='5383' tid='5384' class='u'>; should delete leading spaces
</a>          (<a id='5385' tid='5386' class='u'>save-excursion</a>               <a id='5387' tid='5388' class='u'>; and NIL if not.
</a>            (<a id='5389' tid='5390' class='u'>let</a> ((<a id='5391' tid='5392' class='u'>before-paren</a> (<a id='5393' tid='5394' class='u'>1-</a> (<a id='5395' tid='5396' class='u'>point</a>))))
              (<a id='5397' tid='5398' class='u'>back-to-indentation</a>)
              (<a id='5399' tid='5400' class='u'>cond</a> ((<a id='5401' tid='5402' class='u'>not</a> (<a id='5403' tid='5404' class='u'>eq</a> (<a id='5405' tid='5406' class='u'>point</a>) <a id='5407' tid='5408' class='u'>before-paren</a>))
                     <a id='5409' tid='5410' class='u'>;; Can&#39;t call PAREDIT-DELETE-LEADING-WHITESPACE
</a>                     <a id='5411' tid='5412' class='u'>;; here -- we must return from SAVE-EXCURSION
</a>                     <a id='5413' tid='5414' class='u'>;; first.
</a>                     (<a id='5415' tid='5416' class='u'>throw</a> <a id='5417' tid='5418' class='u'>&#39;</a><a id='5419' tid='5420' class='u'>return</a> <a id='5421' tid='5422' class='u'>t</a>))
                    ((<a id='5423' tid='5424' class='u'>save-excursion</a> (<a id='5425' tid='5426' class='u'>forward-line</a> <a id='5427' tid='5428' class='u'>-1</a>)
                                     (<a id='5429' tid='5430' class='u'>end-of-line</a>)
                                     (<a id='5431' tid='5432' class='u'>paredit-in-comment-p</a>))
                     <a id='5433' tid='5434' class='u'>;; Moving the closing delimiter any further
</a>                     <a id='5435' tid='5436' class='u'>;; would put it into a comment, so we just
</a>                     <a id='5437' tid='5438' class='u'>;; indent the closing delimiter where it is and
</a>                     <a id='5439' tid='5440' class='u'>;; abort the loop, telling its continuation that
</a>                     <a id='5441' tid='5442' class='u'>;; no leading whitespace should be deleted.
</a>                     (<a id='5443' tid='5444' class='u'>lisp-indent-line</a>)
                     (<a id='5445' tid='5446' class='u'>throw</a> <a id='5447' tid='5448' class='u'>&#39;</a><a id='5449' tid='5450' class='u'>return</a> <a id='5451' tid='5452' class='u'>nil</a>))
                    (<a id='5453' tid='5454' class='u'>t</a> (<a id='5455' tid='5456' class='u'>delete-indentation</a>)))))))
      (<a id='5457' tid='5458' class='u'>paredit-delete-leading-whitespace</a>)))

(<a id='5263' tid='5264' class='u'>defun</a> <a id='5265' tid='5266' class='u'>paredit-missing-close</a> ()
  (<a id='5267' tid='5268' class='u'>save-excursion</a>
    (<a id='5269' tid='5270' class='u'>paredit-handle-sexp-errors</a> (<a id='5271' tid='5272' class='u'>backward-up-list</a>)
      (<a id='5273' tid='5274' class='u'>error</a> <a id='5275' tid='5276' class='u'>&quot;Not inside a list.&quot;</a>))
    (<a id='5277' tid='5278' class='u'>let</a> ((<a id='5279' tid='5280' class='u'>open</a> (<a id='5281' tid='5282' class='u'>char-after</a>)))
      (<a id='5283' tid='5284' class='u'>paredit-handle-sexp-errors</a> (<a id='5285' tid='5286' class='u'>progn</a> (<a id='5287' tid='5288' class='u'>forward-sexp</a>) <a id='5289' tid='5290' class='u'>nil</a>)
        <a id='5291' tid='5292' class='u'>open</a>))))

(<a id='2991' tid='2992' class='u'>defun</a> <a id='2993' tid='2994' class='u'>paredit-delete-leading-whitespace</a> ()
  <a id='2995' tid='2996' class='u'>;; This assumes that we&#39;re on the closing delimiter already.
</a>  (<a id='2997' tid='2998' class='u'>save-excursion</a>
    (<a id='2999' tid='3000' class='u'>backward-char</a>)
    (<a id='3001' tid='3002' class='u'>while</a> (<a id='3003' tid='3004' class='u'>let</a> ((<a id='3005' tid='3006' class='u'>syn</a> (<a id='3007' tid='3008' class='u'>char-syntax</a> (<a id='3009' tid='3010' class='u'>char-before</a>))))
             (<a id='3011' tid='3012' class='u'>and</a> (<a id='3013' tid='3014' class='u'>or</a> (<a id='3015' tid='3016' class='u'>eq</a> <a id='3017' tid='3018' class='u'>syn</a> <a id='3019' tid='3020' class='u'>?\ </a>) (<a id='3021' tid='3022' class='u'>eq</a> <a id='3023' tid='3024' class='u'>syn</a> <a id='3025' tid='3026' class='u'>?-</a>))     <a id='3027' tid='3028' class='u'>; whitespace syntax
</a>                  <a id='3029' tid='3030' class='u'>;; The above line is a perfect example of why the
</a>                  <a id='3031' tid='3032' class='u'>;; following test is necessary.
</a>                  (<a id='3033' tid='3034' class='u'>not</a> (<a id='3035' tid='3036' class='u'>paredit-in-char-p</a> (<a id='3037' tid='3038' class='u'>1-</a> (<a id='3039' tid='3040' class='u'>point</a>))))))
      (<a id='3041' tid='3042' class='u'>backward-delete-char</a> <a id='3043' tid='3044' class='u'>1</a>))))

(<a id='2569' tid='2570' class='u'>defun</a> <a id='2571' tid='2572' class='u'>paredit-blink-paren-match</a> (<a id='2573' tid='2574' class='u'>another-line-p</a>)
  (<a id='2575' tid='2576' class='u'>if</a> (<a id='2577' tid='2578' class='u'>and</a> <a id='2579' tid='2580' class='u'>blink-matching-paren</a>
           (<a id='2581' tid='2582' class='u'>or</a> (<a id='2583' tid='2584' class='u'>not</a> <a id='2585' tid='2586' class='u'>show-paren-mode</a>) <a id='2587' tid='2588' class='u'>another-line-p</a>))
      (<a id='2589' tid='2590' class='u'>paredit-ignore-sexp-errors</a>
        (<a id='2591' tid='2592' class='u'>save-excursion</a>
          (<a id='2593' tid='2594' class='u'>backward-sexp</a>)
          (<a id='2595' tid='2596' class='u'>forward-sexp</a>)
          <a id='2597' tid='2598' class='u'>;; SHOW-PAREN-MODE inhibits any blinking, so we disable it
</a>          <a id='2599' tid='2600' class='u'>;; locally here.
</a>          (<a id='2601' tid='2602' class='u'>let</a> ((<a id='2603' tid='2604' class='u'>show-paren-mode</a> <a id='2605' tid='2606' class='u'>nil</a>))
            (<a id='2607' tid='2608' class='u'>blink-matching-open</a>))))))

(<a id='3045' tid='3046' class='u'>defun</a> <a id='3047' tid='3048' class='u'>paredit-doublequote</a> (<a id='3049' tid='3050' class='u'>&optional</a> <a id='3051' tid='3052' class='u'>n</a>)
  <a id='3053' tid='3054' class='u'>&quot;Insert a pair of double-quotes.
With a prefix argument N, wrap the following N S-expressions in
  double-quotes, escaping intermediate characters if necessary.
If the region is active, `transient-mark-mode&#39; is enabled, and the
  region&#39;s start and end fall in the same parenthesis depth, insert a
  pair of double-quotes around the region, again escaping intermediate
  characters if necessary.
Inside a comment, insert a literal double-quote.
At the end of a string, move past the closing double-quote.
In the middle of a string, insert a backslash-escaped double-quote.
If in a character literal, do nothing.  This prevents accidentally
  changing a what was in the character literal to become a meaningful
  delimiter unintentionally.&quot;</a>
  (<a id='3055' tid='3056' class='u'>interactive</a> <a id='3057' tid='3058' class='u'>&quot;P&quot;</a>)
  (<a id='3059' tid='3060' class='u'>cond</a> ((<a id='3061' tid='3062' class='u'>paredit-in-string-p</a>)
         (<a id='3063' tid='3064' class='u'>if</a> (<a id='3065' tid='3066' class='u'>eq</a> (<a id='3067' tid='3068' class='u'>cdr</a> (<a id='3069' tid='3070' class='u'>paredit-string-start+end-points</a>))
                 (<a id='3071' tid='3072' class='u'>point</a>))
             (<a id='3073' tid='3074' class='u'>forward-char</a>)             <a id='3075' tid='3076' class='u'>; We&#39;re on the closing quote.
</a>             (<a id='3077' tid='3078' class='u'>insert</a> <a id='3079' tid='3080' class='u'>?\\</a> <a id='3081' tid='3082' class='u'>?\&quot;</a> )))
        ((<a id='3083' tid='3084' class='u'>paredit-in-comment-p</a>)
         (<a id='3085' tid='3086' class='u'>insert</a> <a id='3087' tid='3088' class='u'>?\&quot;</a> ))
        ((<a id='3089' tid='3090' class='u'>not</a> (<a id='3091' tid='3092' class='u'>paredit-in-char-p</a>))
         (<a id='3093' tid='3094' class='u'>paredit-insert-pair</a> <a id='3095' tid='3096' class='u'>n</a> <a id='3097' tid='3098' class='u'>?\&quot;</a> <a id='3099' tid='3100' class='u'>?\&quot;</a> <a id='3101' tid='3102' class='u'>&#39;</a><a id='3103' tid='3104' class='u'>paredit-forward-for-quote</a>))))

(<a id='5207' tid='5208' class='u'>defun</a> <a id='5209' tid='5210' class='u'>paredit-meta-doublequote</a> (<a id='5211' tid='5212' class='u'>&optional</a> <a id='5213' tid='5214' class='u'>n</a>)
  <a id='5215' tid='5216' class='u'>&quot;Move to the end of the string, insert a newline, and indent.
If not in a string, act as `paredit-doublequote&#39;; if no prefix argument
  is specified and the region is not active or `transient-mark-mode&#39; is
  disabled, the default is to wrap one S-expression, however, not
  zero.&quot;</a>
  (<a id='5217' tid='5218' class='u'>interactive</a> <a id='5219' tid='5220' class='u'>&quot;P&quot;</a>)
  (<a id='5221' tid='5222' class='u'>if</a> (<a id='5223' tid='5224' class='u'>not</a> (<a id='5225' tid='5226' class='u'>paredit-in-string-p</a>))
      (<a id='5227' tid='5228' class='u'>paredit-doublequote</a> (<a id='5229' tid='5230' class='u'>or</a> <a id='5231' tid='5232' class='u'>n</a>
                               (<a id='5233' tid='5234' class='u'>and</a> (<a id='5235' tid='5236' class='u'>not</a> (<a id='5237' tid='5238' class='u'>paredit-region-active-p</a>))
                                    <a id='5239' tid='5240' class='u'>1</a>)))
    (<a id='5241' tid='5242' class='u'>let</a> ((<a id='5243' tid='5244' class='u'>start+end</a> (<a id='5245' tid='5246' class='u'>paredit-string-start+end-points</a>)))
      (<a id='5247' tid='5248' class='u'>goto-char</a> (<a id='5249' tid='5250' class='u'>1+</a> (<a id='5251' tid='5252' class='u'>cdr</a> <a id='5253' tid='5254' class='u'>start+end</a>)))
      (<a id='5255' tid='5256' class='u'>newline</a>)
      (<a id='5257' tid='5258' class='u'>lisp-indent-line</a>)
      (<a id='5259' tid='5260' class='u'>paredit-ignore-sexp-errors</a> (<a id='5261' tid='5262' class='u'>indent-sexp</a>)))))

(<a id='3373' tid='3374' class='u'>defun</a> <a id='3375' tid='3376' class='u'>paredit-forward-for-quote</a> (<a id='3377' tid='3378' class='u'>end</a>)
  (<a id='3379' tid='3380' class='u'>let</a> ((<a id='3381' tid='3382' class='u'>state</a> (<a id='3383' tid='3384' class='u'>paredit-current-parse-state</a>)))
    (<a id='3385' tid='3386' class='u'>while</a> (<a id='3387' tid='3388' class='u'>&lt;</a> (<a id='3389' tid='3390' class='u'>point</a>) <a id='3391' tid='3392' class='u'>end</a>)
      (<a id='3393' tid='3394' class='u'>let</a> ((<a id='3395' tid='3396' class='u'>new-state</a> (<a id='3397' tid='3398' class='u'>parse-partial-sexp</a> (<a id='3399' tid='3400' class='u'>point</a>) (<a id='3401' tid='3402' class='u'>1+</a> (<a id='3403' tid='3404' class='u'>point</a>))
                                           <a id='3405' tid='3406' class='u'>nil</a> <a id='3407' tid='3408' class='u'>nil</a> <a id='3409' tid='3410' class='u'>state</a>)))
        (<a id='3411' tid='3412' class='u'>if</a> (<a id='3413' tid='3414' class='u'>paredit-in-string-p</a> <a id='3415' tid='3416' class='u'>new-state</a>)
            (<a id='3417' tid='3418' class='u'>if</a> (<a id='3419' tid='3420' class='u'>not</a> (<a id='3421' tid='3422' class='u'>paredit-in-string-escape-p</a>))
                (<a id='3423' tid='3424' class='u'>setq</a> <a id='3425' tid='3426' class='u'>state</a> <a id='3427' tid='3428' class='u'>new-state</a>)
              <a id='3429' tid='3430' class='u'>;; Escape character: turn it into an escaped escape
</a>              <a id='3431' tid='3432' class='u'>;; character by appending another backslash.
</a>              (<a id='3433' tid='3434' class='u'>insert</a> <a id='3435' tid='3436' class='u'>?\\</a> )
              <a id='3437' tid='3438' class='u'>;; Now the point is after both escapes, and we want to
</a>              <a id='3439' tid='3440' class='u'>;; rescan from before the first one to after the second
</a>              <a id='3441' tid='3442' class='u'>;; one.
</a>              (<a id='3443' tid='3444' class='u'>setq</a> <a id='3445' tid='3446' class='u'>state</a>
                    (<a id='3447' tid='3448' class='u'>parse-partial-sexp</a> (<a id='3449' tid='3450' class='u'>-</a> (<a id='3451' tid='3452' class='u'>point</a>) <a id='3453' tid='3454' class='u'>2</a>) (<a id='3455' tid='3456' class='u'>point</a>)
                                        <a id='3457' tid='3458' class='u'>nil</a> <a id='3459' tid='3460' class='u'>nil</a> <a id='3461' tid='3462' class='u'>state</a>))
              <a id='3463' tid='3464' class='u'>;; Advance the end point, since we just inserted a new
</a>              <a id='3465' tid='3466' class='u'>;; character.
</a>              (<a id='3467' tid='3468' class='u'>setq</a> <a id='3469' tid='3470' class='u'>end</a> (<a id='3471' tid='3472' class='u'>1+</a> <a id='3473' tid='3474' class='u'>end</a>)))
          <a id='3475' tid='3476' class='u'>;; String: escape by inserting a backslash before the quote.
</a>          (<a id='3477' tid='3478' class='u'>backward-char</a>)
          (<a id='3479' tid='3480' class='u'>insert</a> <a id='3481' tid='3482' class='u'>?\\</a> )
          <a id='3483' tid='3484' class='u'>;; The point is now between the escape and the quote, and we
</a>          <a id='3485' tid='3486' class='u'>;; want to rescan from before the escape to after the quote.
</a>          (<a id='3487' tid='3488' class='u'>setq</a> <a id='3489' tid='3490' class='u'>state</a>
                (<a id='3491' tid='3492' class='u'>parse-partial-sexp</a> (<a id='3493' tid='3494' class='u'>1-</a> (<a id='3495' tid='3496' class='u'>point</a>)) (<a id='3497' tid='3498' class='u'>1+</a> (<a id='3499' tid='3500' class='u'>point</a>))
                                    <a id='3501' tid='3502' class='u'>nil</a> <a id='3503' tid='3504' class='u'>nil</a> <a id='3505' tid='3506' class='u'>state</a>))
          <a id='3507' tid='3508' class='u'>;; Advance the end point for the same reason as above.
</a>          (<a id='3509' tid='3510' class='u'>setq</a> <a id='3511' tid='3512' class='u'>end</a> (<a id='3513' tid='3514' class='u'>1+</a> <a id='3515' tid='3516' class='u'>end</a>)))))))

<span class='d'>;;;; Escape Insertion
</span>
(<a id='2025' tid='2026' class='u'>defun</a> <a id='2027' tid='2028' class='u'>paredit-backslash</a> ()
  <a id='2029' tid='2030' class='u'>&quot;Insert a backslash followed by a character to escape.&quot;</a>
  (<a id='2031' tid='2032' class='u'>interactive</a>)
  <span class='d'>(insert ?\\ )</span>
  <span class='d'>;; This funny conditional is necessary because PAREDIT-IN-COMMENT-P
</span>  <span class='d'>;; assumes that PAREDIT-IN-STRING-P already returned false; otherwise
</span>  <span class='d'>;; it may give erroneous answers.
</span>  <span class='d'>(if (or (paredit-in-string-p)
          (not (paredit-in-comment-p)))
      (let ((delp t))
        (unwind-protect (setq delp
                              (call-interactively &#39;paredit-escape))
          ;; We need this in an UNWIND-PROTECT so that the backlash is
          ;; left in there *only* if PAREDIT-ESCAPE return NIL normally
          ;; -- in any other case, such as the user hitting C-g or an
          ;; error occurring, we must delete the backslash to avoid
          ;; leaving a dangling escape.  (This control structure is a
          ;; crock.)
          (if delp (backward-delete-char 1)))))</span>)

<span class='d'>;;; This auxiliary interactive function returns true if the backslash
</span><span class='d'>;;; should be deleted and false if not.
</span>
<span class='d'>(defun paredit-escape (char)
  ;; I&#39;m too lazy to figure out how to do this without a separate
  ;; interactive function.
  (interactive &quot;cEscaping character...&quot;)
  (if (eq char 127)                     ; The backslash was a typo, so
      t                                 ; the luser wants to delete it.
    (insert char)                       ; (Is there a better way to
    nil))</span>                               <span class='d'>; express the rubout char?
</span>                                        <span class='d'>; ?\^? works, but ugh...)
</span>
(<a id='5459' tid='5460' class='u'>defun</a> <a id='5461' tid='5462' class='u'>paredit-newline</a> ()
  <a id='5463' tid='5464' class='u'>&quot;Insert a newline and indent it.
This is like `newline-and-indent&#39;, but it not only indents the line
  that the point is on but also the S-expression following the point,
  if there is one.
Move forward one character first if on an escaped character.
If in a string, just insert a literal newline.
If in a comment and if followed by invalid structure, call
  `indent-new-comment-line&#39; to keep the invalid structure in a
  comment.&quot;</a>
  (<a id='5465' tid='5466' class='u'>interactive</a>)
  (<span class='d'>cond</span> <span class='d'>((paredit-in-string-p)
         (newline))</span>
        <span class='d'>((paredit-in-comment-p)
         (if (paredit-region-ok-p (point) (point-at-eol))
             (progn (newline-and-indent) (indent-sexp))
             (indent-new-comment-line)))</span>
        (<a id='1077' tid='1078' class='m'>t</a>
         (<a id='1079' tid='1080' class='m'>if</a> (<a id='1081' tid='1082' class='m'>paredit-in-char-p</a>)
             (<a id='1083' tid='1084' class='m'>forward-char</a>))
         (<a id='1085' tid='1086' class='m'>newline-and-indent</a>)
         <a id='1087' tid='1088' class='m'>;; Indent the following S-expression, but don&#39;t signal an
</a>         <a id='1089' tid='1090' class='m'>;; error if there&#39;s only a closing delimiter after the point.
</a>         (<a id='1091' tid='1092' class='m'>paredit-ignore-sexp-errors</a> (<a id='1093' tid='1094' class='m'>indent-sexp</a>)))))

(<a id='5837' tid='5838' class='u'>defun</a> <a id='5839' tid='5840' class='u'>paredit-reindent-defun</a> (<a id='5841' tid='5842' class='u'>&optional</a> <a id='5843' tid='5844' class='u'>argument</a>)
  <a id='5845' tid='5846' class='u'>&quot;Reindent the definition that the point is on.
If the point is in a string or a comment, fill the paragraph instead,
  and with a prefix argument, justify as well.&quot;</a>
  (<a id='5847' tid='5848' class='u'>interactive</a> <a id='5849' tid='5850' class='u'>&quot;P&quot;</a>)
  <span class='d'>(if (or (paredit-in-string-p)
          (paredit-in-comment-p))
      (fill-paragraph argument)
    (save-excursion
      (end-of-defun)
      (beginning-of-defun)
      (indent-sexp)))</span>)

<span class='d'>;;;; Comment Insertion
</span>
(<a id='5851' tid='5852' class='u'>defun</a> <a id='5853' tid='5854' class='u'>paredit-semicolon</a> (<a id='5855' tid='5856' class='u'>&optional</a> <a id='5857' tid='5858' class='u'>n</a>)
  <a id='5859' tid='5860' class='u'>&quot;Insert a semicolon.
With a prefix argument N, insert N semicolons.
If in a string, do just that and nothing else.
If in a character literal, move to the beginning of the character
  literal before inserting the semicolon.
If the enclosing list ends on the line after the point, break the line
  after the last S-expression following the point.
If a list begins on the line after the point but ends on a different
  line, break the line after the last S-expression following the point
  before the list.&quot;</a>
  (<a id='5861' tid='5862' class='u'>interactive</a> <a id='5863' tid='5864' class='u'>&quot;p&quot;</a>)
  (<a id='5865' tid='5866' class='u'>if</a> (<a id='5867' tid='5868' class='u'>or</a> (<a id='5869' tid='5870' class='u'>paredit-in-string-p</a>) (<a id='5871' tid='5872' class='u'>paredit-in-comment-p</a>))
      (<a id='5873' tid='5874' class='u'>insert</a> (<a id='5875' tid='5876' class='u'>make-string</a> (<a id='5877' tid='5878' class='u'>or</a> <a id='5879' tid='5880' class='u'>n</a> <a id='5881' tid='5882' class='u'>1</a>) <a id='5883' tid='5884' class='u'>?\;</a> ))
    (<a id='5885' tid='5886' class='u'>if</a> (<a id='5887' tid='5888' class='u'>paredit-in-char-p</a>)
        (<a id='5889' tid='5890' class='u'>backward-char</a> <a id='5891' tid='5892' class='u'>2</a>))
    (<a id='5893' tid='5894' class='u'>let</a> ((<a id='5895' tid='5896' class='u'>line-break-point</a> (<a id='5897' tid='5898' class='u'>paredit-semicolon-find-line-break-point</a>)))
      (<a id='5899' tid='5900' class='u'>if</a> <a id='5901' tid='5902' class='u'>line-break-point</a>
          (<a id='5903' tid='5904' class='u'>paredit-semicolon-with-line-break</a> <a id='5905' tid='5906' class='u'>line-break-point</a> (<a id='5907' tid='5908' class='u'>or</a> <a id='5909' tid='5910' class='u'>n</a> <a id='5911' tid='5912' class='u'>1</a>))
          (<a id='5913' tid='5914' class='u'>insert</a> (<a id='5915' tid='5916' class='u'>make-string</a> (<a id='5917' tid='5918' class='u'>or</a> <a id='5919' tid='5920' class='u'>n</a> <a id='5921' tid='5922' class='u'>1</a>) <a id='5923' tid='5924' class='u'>?\;</a> ))))))

(<a id='5925' tid='5926' class='u'>defun</a> <a id='5927' tid='5928' class='u'>paredit-semicolon-find-line-break-point</a> ()
  (<a id='1095' tid='1096' class='m'>let</a> ((<a id='1097' tid='1098' class='m'>line-break-point</a> <a id='1099' tid='1100' class='m'>nil</a>)
        (<a id='1101' tid='1102' class='m'>eol</a> (<a id='1103' tid='1104' class='m'>point-at-eol</a>)))
    (<span class='d'>and</span> (<span class='d'>save-excursion</span>
           (<a id='549' tid='550' class='m'>paredit-handle-sexp-errors</a>
               (<span class='d'>progn</span>
                 (<a id='1105' tid='1106' class='m'>while</a>
                     (<a id='1107' tid='1108' class='m'>progn</a>
                       (<a id='1109' tid='1110' class='m'>setq</a> <a id='1111' tid='1112' class='m'>line-break-point</a> (<a id='1113' tid='1114' class='m'>point</a>))
                       (<a id='1115' tid='1116' class='m'>forward-sexp</a>)
                       (<a id='1117' tid='1118' class='m'>and</a> (<a id='1119' tid='1120' class='m'>eq</a> <a id='1121' tid='1122' class='m'>eol</a> (<a id='1123' tid='1124' class='m'>point-at-eol</a>))
                            (<a id='1125' tid='1126' class='m'>not</a> (<a id='1127' tid='1128' class='m'>eobp</a>)))))
                 <span class='d'>(backward-sexp)</span>
                 <span class='d'>(eq eol (point-at-eol))</span>)
             <a id='551' tid='552' class='m'>;; If we hit the end of an expression, but the closing
</a>             <a id='553' tid='554' class='m'>;; delimiter is on another line, don&#39;t break the line.
</a>             (<a id='555' tid='556' class='m'>save-excursion</a>
               (<a id='557' tid='558' class='m'>paredit-skip-whitespace</a> <a id='559' tid='560' class='m'>t</a> (<a id='561' tid='562' class='m'>point-at-eol</a>))
               (<a id='563' tid='564' class='m'>not</a> (<a id='565' tid='566' class='m'>or</a> (<a id='567' tid='568' class='m'>eolp</a>) (<a id='569' tid='570' class='m'>eq</a> (<a id='571' tid='572' class='m'>char-after</a>) <a id='573' tid='574' class='m'>?\;</a> ))))))
         <span class='d'>line-break-point</span>)))

(<a id='5929' tid='5930' class='u'>defun</a> <a id='5931' tid='5932' class='u'>paredit-semicolon-with-line-break</a> (<a id='5933' tid='5934' class='u'>line-break-point</a> <a id='5935' tid='5936' class='u'>n</a>)
  (<a id='5937' tid='5938' class='u'>let</a> ((<a id='5939' tid='5940' class='u'>line-break-marker</a> (<a id='5941' tid='5942' class='u'>make-marker</a>)))
    (<a id='5943' tid='5944' class='u'>set-marker</a> <a id='5945' tid='5946' class='u'>line-break-marker</a> <a id='5947' tid='5948' class='u'>line-break-point</a>)
    (<a id='5949' tid='5950' class='u'>set-marker-insertion-type</a> <a id='5951' tid='5952' class='u'>line-break-marker</a> <a id='5953' tid='5954' class='u'>t</a>)
    (<a id='5955' tid='5956' class='u'>insert</a> (<a id='5957' tid='5958' class='u'>make-string</a> (<a id='5959' tid='5960' class='u'>or</a> <a id='5961' tid='5962' class='u'>n</a> <a id='5963' tid='5964' class='u'>1</a>) <a id='5965' tid='5966' class='u'>?\;</a> ))
    (<a id='5967' tid='5968' class='u'>save-excursion</a>
      (<a id='5969' tid='5970' class='u'>goto-char</a> <a id='5971' tid='5972' class='u'>line-break-marker</a>)
      (<a id='5973' tid='5974' class='u'>set-marker</a> <a id='5975' tid='5976' class='u'>line-break-marker</a> <a id='5977' tid='5978' class='u'>nil</a>)
      (<a id='5979' tid='5980' class='u'>newline</a>)
      (<a id='5981' tid='5982' class='u'>lisp-indent-line</a>)
      <a id='5983' tid='5984' class='u'>;; This step is redundant if we are inside a list, but even if we
</a>      <a id='5985' tid='5986' class='u'>;; are at the top level, we want at least to indent whatever we
</a>      <a id='5987' tid='5988' class='u'>;; bumped off the line.
</a>      (<a id='5989' tid='5990' class='u'>paredit-ignore-sexp-errors</a> (<a id='5991' tid='5992' class='u'>indent-sexp</a>))
      (<a id='5993' tid='5994' class='u'>paredit-indent-sexps</a>))))

<span class='d'>;;; This is all a horrible, horrible hack, primarily for GNU Emacs 21,
</span><span class='d'>;;; in which there is no `comment-or-uncomment-region&#39;.
</span>
(<a id='7303' tid='7304' class='u'>autoload</a> <a id='7305' tid='7306' class='u'>&#39;</a><a id='7307' tid='7308' class='u'>comment-forward</a> <a id='7309' tid='7310' class='u'>&quot;newcomment&quot;</a>)
(<a id='7311' tid='7312' class='u'>autoload</a> <a id='7313' tid='7314' class='u'>&#39;</a><a id='7315' tid='7316' class='u'>comment-normalize-vars</a> <a id='7317' tid='7318' class='u'>&quot;newcomment&quot;</a>)
(<a id='7319' tid='7320' class='u'>autoload</a> <a id='7321' tid='7322' class='u'>&#39;</a><a id='7323' tid='7324' class='u'>comment-region</a> <a id='7325' tid='7326' class='u'>&quot;newcomment&quot;</a>)
(<a id='7327' tid='7328' class='u'>autoload</a> <a id='7329' tid='7330' class='u'>&#39;</a><a id='7331' tid='7332' class='u'>comment-search-forward</a> <a id='7333' tid='7334' class='u'>&quot;newcomment&quot;</a>)
(<a id='7335' tid='7336' class='u'>autoload</a> <a id='7337' tid='7338' class='u'>&#39;</a><a id='7339' tid='7340' class='u'>uncomment-region</a> <a id='7341' tid='7342' class='u'>&quot;newcomment&quot;</a>)

(<a id='4171' tid='4172' class='u'>defun</a> <a id='4173' tid='4174' class='u'>paredit-initialize-comment-dwim</a> ()
  (<a id='4175' tid='4176' class='u'>require</a> <a id='4177' tid='4178' class='u'>&#39;</a><a id='4179' tid='4180' class='u'>newcomment</a>)
  (<a id='4181' tid='4182' class='u'>if</a> (<a id='4183' tid='4184' class='u'>not</a> (<a id='4185' tid='4186' class='u'>fboundp</a> <a id='4187' tid='4188' class='u'>&#39;</a><a id='4189' tid='4190' class='u'>comment-or-uncomment-region</a>))
      (<a id='4191' tid='4192' class='u'>defalias</a> <a id='4193' tid='4194' class='u'>&#39;</a><a id='4195' tid='4196' class='u'>comment-or-uncomment-region</a>
        (<a id='4197' tid='4198' class='u'>lambda</a> (<a id='4199' tid='4200' class='u'>beginning</a> <a id='4201' tid='4202' class='u'>end</a> <a id='4203' tid='4204' class='u'>&optional</a> <a id='4205' tid='4206' class='u'>argument</a>)
          (<a id='4207' tid='4208' class='u'>interactive</a> <a id='4209' tid='4210' class='u'>&quot;*r\nP&quot;</a>)
          (<a id='4211' tid='4212' class='u'>if</a> (<a id='4213' tid='4214' class='u'>save-excursion</a> (<a id='4215' tid='4216' class='u'>goto-char</a> <a id='4217' tid='4218' class='u'>beginning</a>)
                              (<a id='4219' tid='4220' class='u'>comment-forward</a> (<a id='4221' tid='4222' class='u'>point-max</a>))
                              (<a id='4223' tid='4224' class='u'>&lt;=</a> <a id='4225' tid='4226' class='u'>end</a> (<a id='4227' tid='4228' class='u'>point</a>)))
              (<a id='4229' tid='4230' class='u'>uncomment-region</a> <a id='4231' tid='4232' class='u'>beginning</a> <a id='4233' tid='4234' class='u'>end</a> <a id='4235' tid='4236' class='u'>argument</a>)
              (<a id='4237' tid='4238' class='u'>comment-region</a> <a id='4239' tid='4240' class='u'>beginning</a> <a id='4241' tid='4242' class='u'>end</a> <a id='4243' tid='4244' class='u'>argument</a>)))))
  (<a id='4245' tid='4246' class='u'>defalias</a> <a id='4247' tid='4248' class='u'>&#39;</a><a id='4249' tid='4250' class='u'>paredit-initialize-comment-dwim</a> <a id='4251' tid='4252' class='u'>&#39;</a><a id='4253' tid='4254' class='u'>comment-normalize-vars</a>)
  (<a id='4255' tid='4256' class='u'>comment-normalize-vars</a>))

(<a id='2625' tid='2626' class='u'>defun</a> <a id='2627' tid='2628' class='u'>paredit-comment-dwim</a> (<a id='2629' tid='2630' class='u'>&optional</a> <a id='2631' tid='2632' class='u'>argument</a>)
  <a id='2633' tid='2634' class='u'>&quot;Call the Lisp comment command you want (Do What I Mean).
This is like `comment-dwim&#39;, but it is specialized for Lisp editing.
If transient mark mode is enabled and the mark is active, comment or
  uncomment the selected region, depending on whether it was entirely
  commented not not already.
If there is already a comment on the current line, with no prefix
  argument, indent to that comment; with a prefix argument, kill that
  comment.
Otherwise, insert a comment appropriate for the context and ensure that
  any code following the comment is moved to the next line.
At the top level, where indentation is calculated to be at column 0,
  insert a triple-semicolon comment; within code, where the indentation
  is calculated to be non-zero, and on the line there is either no code
  at all or code after the point, insert a double-semicolon comment;
  and if the point is after all code on the line, insert a single-
  semicolon margin comment at `comment-column&#39;.&quot;</a>
  (<a id='2635' tid='2636' class='u'>interactive</a> <a id='2637' tid='2638' class='u'>&quot;*P&quot;</a>)
  (<a id='2639' tid='2640' class='u'>paredit-initialize-comment-dwim</a>)
  (<a id='2641' tid='2642' class='u'>cond</a> ((<a id='2643' tid='2644' class='u'>paredit-region-active-p</a>)
         (<a id='2645' tid='2646' class='u'>comment-or-uncomment-region</a> (<a id='2647' tid='2648' class='u'>region-beginning</a>)
                                      (<a id='2649' tid='2650' class='u'>region-end</a>)
                                      <a id='2651' tid='2652' class='u'>argument</a>))
        ((<a id='2653' tid='2654' class='u'>paredit-comment-on-line-p</a>)
         (<a id='2655' tid='2656' class='u'>if</a> <a id='2657' tid='2658' class='u'>argument</a>
             (<a id='2659' tid='2660' class='u'>comment-kill</a> (<a id='2661' tid='2662' class='u'>if</a> (<a id='2663' tid='2664' class='u'>integerp</a> <a id='2665' tid='2666' class='u'>argument</a>) <a id='2667' tid='2668' class='u'>argument</a> <a id='2669' tid='2670' class='u'>nil</a>))
             (<a id='2671' tid='2672' class='u'>comment-indent</a>)))
        (<a id='2673' tid='2674' class='u'>t</a> (<a id='2675' tid='2676' class='u'>paredit-insert-comment</a>))))

(<a id='2677' tid='2678' class='u'>defun</a> <a id='2679' tid='2680' class='u'>paredit-comment-on-line-p</a> ()
  <a id='2681' tid='2682' class='u'>&quot;True if there is a comment on the line following point.
This is expected to be called only in `paredit-comment-dwim&#39;; do not
  call it elsewhere.&quot;</a>
  (<a id='2683' tid='2684' class='u'>save-excursion</a>
    (<a id='2685' tid='2686' class='u'>beginning-of-line</a>)
    (<a id='2687' tid='2688' class='u'>let</a> ((<a id='2689' tid='2690' class='u'>comment-p</a> <a id='2691' tid='2692' class='u'>nil</a>))
      <a id='2693' tid='2694' class='u'>;; Search forward for a comment beginning.  If there is one, set
</a>      <a id='2695' tid='2696' class='u'>;; COMMENT-P to true; if not, it will be nil.
</a>      (<a id='2697' tid='2698' class='u'>while</a> (<a id='2699' tid='2700' class='u'>progn</a>
               (<a id='2701' tid='2702' class='u'>setq</a> <a id='2703' tid='2704' class='u'>comment-p</a>          <a id='2705' tid='2706' class='u'>;t -&gt; no error
</a>                     (<a id='2707' tid='2708' class='u'>comment-search-forward</a> (<a id='2709' tid='2710' class='u'>point-at-eol</a>) <a id='2711' tid='2712' class='u'>t</a>))
               (<a id='2713' tid='2714' class='u'>and</a> <a id='2715' tid='2716' class='u'>comment-p</a>
                    (<a id='2717' tid='2718' class='u'>or</a> (<a id='2719' tid='2720' class='u'>paredit-in-string-p</a>)
                        (<a id='2721' tid='2722' class='u'>paredit-in-char-p</a> (<a id='2723' tid='2724' class='u'>1-</a> (<a id='2725' tid='2726' class='u'>point</a>))))))
        (<a id='2727' tid='2728' class='u'>forward-char</a>))
      <a id='2729' tid='2730' class='u'>comment-p</a>)))

(<a id='4257' tid='4258' class='u'>defun</a> <a id='4259' tid='4260' class='u'>paredit-insert-comment</a> ()
  (<a id='1129' tid='1130' class='m'>let</a> ((<a id='1131' tid='1132' class='m'>code-after-p</a>
         (<a id='1133' tid='1134' class='m'>save-excursion</a> (<a id='1135' tid='1136' class='m'>paredit-skip-whitespace</a> <a id='1137' tid='1138' class='m'>t</a> (<a id='1139' tid='1140' class='m'>point-at-eol</a>))
                         (<a id='1141' tid='1142' class='m'>not</a> (<a id='1143' tid='1144' class='m'>eolp</a>))))
        (<a id='1145' tid='1146' class='m'>code-before-p</a>
         (<a id='1147' tid='1148' class='m'>save-excursion</a> (<a id='1149' tid='1150' class='m'>paredit-skip-whitespace</a> <a id='1151' tid='1152' class='m'>nil</a> (<a id='1153' tid='1154' class='m'>point-at-bol</a>))
                         (<a id='1155' tid='1156' class='m'>not</a> (<a id='1157' tid='1158' class='m'>bolp</a>)))))
    (<a id='1159' tid='1160' class='m'>cond</a> ((<a id='1161' tid='1162' class='m'>and</a> (<a id='1163' tid='1164' class='m'>bolp</a>)
                (<a id='1165' tid='1166' class='m'>let</a> ((<a id='1167' tid='1168' class='m'>indent</a>
                       (<a id='1169' tid='1170' class='m'>let</a> ((<a id='1171' tid='1172' class='m'>indent</a> (<a id='1173' tid='1174' class='m'>calculate-lisp-indent</a>)))
                         (<a id='1175' tid='1176' class='m'>if</a> (<a id='1177' tid='1178' class='m'>consp</a> <a id='1179' tid='1180' class='m'>indent</a>) (<a id='1181' tid='1182' class='m'>car</a> <a id='1183' tid='1184' class='m'>indent</a>) <a id='1185' tid='1186' class='m'>indent</a>))))
                  (<a id='1187' tid='1188' class='m'>and</a> <a id='1189' tid='1190' class='m'>indent</a> (<a id='1191' tid='1192' class='m'>zerop</a> <a id='1193' tid='1194' class='m'>indent</a>))))
           <a id='1195' tid='1196' class='m'>;; Top-level comment
</a>           (<a id='1197' tid='1198' class='m'>if</a> <a id='1199' tid='1200' class='m'>code-after-p</a> (<a id='1201' tid='1202' class='m'>save-excursion</a> (<a id='1203' tid='1204' class='m'>newline</a>)))
           (<a id='1205' tid='1206' class='m'>insert</a> <a id='1207' tid='1208' class='m'>&quot;;;; &quot;</a>))
          (<span class='d'>(or code-after-p (not code-before-p))</span>
           <span class='d'>;; Code comment
</span>           <span class='d'>(if code-before-p (newline))</span>
           <span class='d'>(lisp-indent-line)</span>
           <span class='d'>(insert &quot;;; &quot;)</span>
           (<a id='1209' tid='1210' class='m'>if</a> <a id='1211' tid='1212' class='m'>code-after-p</a>
               (<a id='1213' tid='1214' class='m'>save-excursion</a>
                 (<a id='1215' tid='1216' class='m'>newline</a>)
                 (<a id='1217' tid='1218' class='m'>lisp-indent-line</a>)
                 (<a id='1219' tid='1220' class='m'>paredit-indent-sexps</a>))))
          (<a id='1221' tid='1222' class='m'>t</a>
           <a id='1223' tid='1224' class='m'>;; Margin comment
</a>           (<a id='1225' tid='1226' class='m'>indent-to</a> <a id='1227' tid='1228' class='m'>comment-column</a> <a id='1229' tid='1230' class='m'>1</a>) <a id='1231' tid='1232' class='m'>; 1 -&gt; force one leading space
</a>           (<a id='1233' tid='1234' class='m'>insert</a> <a id='1235' tid='1236' class='m'>?\;</a> )))))

<a id='7343' tid='7344' class='u'>;;;; Character Deletion
</a>
(<a id='3231' tid='3232' class='u'>defun</a> <a id='3233' tid='3234' class='u'>paredit-forward-delete</a> (<a id='3235' tid='3236' class='u'>&optional</a> <a id='3237' tid='3238' class='u'>argument</a>)
  <a id='3239' tid='3240' class='u'>&quot;Delete a character forward or move forward over a delimiter.
If on an opening S-expression delimiter, move forward into the
  S-expression.
If on a closing S-expression delimiter, refuse to delete unless the
  S-expression is empty, in which case delete the whole S-expression.
With a numeric prefix argument N, delete N characters forward.
With a `C-u&#39; prefix argument, simply delete a character forward,
  without regard for delimiter balancing.&quot;</a>
  (<a id='3241' tid='3242' class='u'>interactive</a> <a id='3243' tid='3244' class='u'>&quot;P&quot;</a>)
  (<span class='d'>cond</span> ((<a id='1237' tid='1238' class='m'>or</a> (<a id='1239' tid='1240' class='m'>consp</a> <a id='1241' tid='1242' class='m'>argument</a>) (<a id='1243' tid='1244' class='m'>eobp</a>))
         (<a id='1245' tid='1246' class='m'>delete-char</a> <a id='1247' tid='1248' class='m'>1</a>))
        ((<a id='575' tid='576' class='m'>integerp</a> <a id='577' tid='578' class='m'>argument</a>)
         (<a id='579' tid='580' class='m'>if</a> (<a id='581' tid='582' class='m'>&lt;</a> <a id='583' tid='584' class='m'>argument</a> <a id='585' tid='586' class='m'>0</a>)
             (<a id='587' tid='588' class='m'>paredit-backward-delete</a> <a id='589' tid='590' class='m'>argument</a>)
             (<a id='591' tid='592' class='m'>while</a> (<a id='593' tid='594' class='m'>&gt;</a> <a id='595' tid='596' class='m'>argument</a> <a id='597' tid='598' class='m'>0</a>)
               (<a id='599' tid='600' class='m'>paredit-forward-delete</a>)
               (<a id='601' tid='602' class='m'>setq</a> <a id='603' tid='604' class='m'>argument</a> (<a id='605' tid='606' class='m'>-</a> <a id='607' tid='608' class='m'>argument</a> <a id='609' tid='610' class='m'>1</a>)))))
        <span class='d'>((paredit-in-string-p)
         (paredit-forward-delete-in-string))</span>
        <span class='d'>((paredit-in-comment-p)
         ;++ What to do here?  This could move a partial S-expression
         ;++ into a comment and thereby invalidate the file&#39;s form,
         ;++ or move random text out of a comment.
         (delete-char 1))</span>
        ((<a id='471' tid='472' class='m'>paredit-in-char-p</a>)            <a id='473' tid='474' class='m'>; Escape -- delete both chars.
</a>         (<a id='475' tid='476' class='m'>backward-delete-char</a> <a id='477' tid='478' class='m'>1</a>)
         (<a id='479' tid='480' class='m'>delete-char</a> <a id='481' tid='482' class='m'>1</a>))
        ((<a id='437' tid='438' class='m'>eq</a> (<a id='439' tid='440' class='m'>char-after</a>) <a id='441' tid='442' class='m'>?\\</a> )         <a id='443' tid='444' class='m'>; ditto
</a>         (<a id='445' tid='446' class='m'>delete-char</a> <a id='447' tid='448' class='m'>2</a>))
        ((<a id='333' tid='334' class='m'>let</a> ((<a id='335' tid='336' class='m'>syn</a> (<a id='337' tid='338' class='m'>char-syntax</a> (<a id='339' tid='340' class='m'>char-after</a>))))
           (<a id='341' tid='342' class='m'>or</a> (<a id='343' tid='344' class='m'>eq</a> <a id='345' tid='346' class='m'>syn</a> <a id='347' tid='348' class='m'>?\(</a> )
               (<a id='349' tid='350' class='m'>eq</a> <a id='351' tid='352' class='m'>syn</a> <a id='353' tid='354' class='m'>?\&quot;</a> )))
         (<a id='355' tid='356' class='m'>if</a> (<a id='357' tid='358' class='m'>save-excursion</a>
               (<a id='359' tid='360' class='m'>paredit-handle-sexp-errors</a> (<a id='361' tid='362' class='m'>progn</a> (<a id='363' tid='364' class='m'>forward-sexp</a>) <a id='365' tid='366' class='m'>t</a>)
                 <a id='367' tid='368' class='m'>nil</a>))
             (<a id='369' tid='370' class='m'>forward-char</a>)
           (<a id='371' tid='372' class='m'>message</a> <a id='373' tid='374' class='m'>&quot;Deleting spurious opening delimiter.&quot;</a>)
           (<a id='375' tid='376' class='m'>delete-char</a> <a id='377' tid='378' class='m'>1</a>)))
        ((<a id='251' tid='252' class='m'>and</a> (<a id='253' tid='254' class='m'>not</a> (<a id='255' tid='256' class='m'>paredit-in-char-p</a> (<a id='257' tid='258' class='m'>1-</a> (<a id='259' tid='260' class='m'>point</a>))))
              (<a id='261' tid='262' class='m'>eq</a> (<a id='263' tid='264' class='m'>char-syntax</a> (<a id='265' tid='266' class='m'>char-after</a>)) <a id='267' tid='268' class='m'>?\)</a> )
              (<a id='269' tid='270' class='m'>eq</a> (<a id='271' tid='272' class='m'>char-before</a>) (<a id='273' tid='274' class='m'>matching-paren</a> (<a id='275' tid='276' class='m'>char-after</a>))))
         (<a id='277' tid='278' class='m'>backward-delete-char</a> <a id='279' tid='280' class='m'>1</a>)       <a id='281' tid='282' class='m'>; Empty list -- delete both
</a>         (<a id='283' tid='284' class='m'>delete-char</a> <a id='285' tid='286' class='m'>1</a>))               <span class='d'>;   delimiters.
</span>        <span class='d'>;; Just delete a single character, if it&#39;s not a closing
</span>        <span class='d'>;; delimiter.  (The character literal case is already handled
</span>        <span class='d'>;; by now.)
</span>        ((<a id='197' tid='198' class='m'>not</a> (<a id='199' tid='200' class='m'>eq</a> (<a id='201' tid='202' class='m'>char-syntax</a> (<a id='203' tid='204' class='m'>char-after</a>)) <a id='205' tid='206' class='m'>?\)</a> ))
         (<a id='207' tid='208' class='m'>delete-char</a> <a id='209' tid='210' class='m'>1</a>))))

(<a id='3245' tid='3246' class='u'>defun</a> <a id='3247' tid='3248' class='u'>paredit-forward-delete-in-string</a> ()
  (<a id='3249' tid='3250' class='u'>let</a> ((<a id='3251' tid='3252' class='u'>start+end</a> (<a id='3253' tid='3254' class='u'>paredit-string-start+end-points</a>)))
    (<a id='3255' tid='3256' class='u'>cond</a> ((<a id='3257' tid='3258' class='u'>not</a> (<a id='3259' tid='3260' class='u'>eq</a> (<a id='3261' tid='3262' class='u'>point</a>) (<a id='3263' tid='3264' class='u'>cdr</a> <a id='3265' tid='3266' class='u'>start+end</a>)))
           <a id='3267' tid='3268' class='u'>;; If it&#39;s not the close-quote, it&#39;s safe to delete.  But
</a>           <a id='3269' tid='3270' class='u'>;; first handle the case that we&#39;re in a string escape.
</a>           (<a id='3271' tid='3272' class='u'>cond</a> ((<a id='3273' tid='3274' class='u'>paredit-in-string-escape-p</a>)
                  <a id='3275' tid='3276' class='u'>;; We&#39;re right after the backslash, so backward
</a>                  <a id='3277' tid='3278' class='u'>;; delete it before deleting the escaped character.
</a>                  (<a id='3279' tid='3280' class='u'>backward-delete-char</a> <a id='3281' tid='3282' class='u'>1</a>))
                 ((<a id='3283' tid='3284' class='u'>eq</a> (<a id='3285' tid='3286' class='u'>char-after</a>) <a id='3287' tid='3288' class='u'>?\\</a> )
                  <a id='3289' tid='3290' class='u'>;; If we&#39;re not in a string escape, but we are on a
</a>                  <a id='3291' tid='3292' class='u'>;; backslash, it must start the escape for the next
</a>                  <a id='3293' tid='3294' class='u'>;; character, so delete the backslash before deleting
</a>                  <a id='3295' tid='3296' class='u'>;; the next character.
</a>                  (<a id='3297' tid='3298' class='u'>delete-char</a> <a id='3299' tid='3300' class='u'>1</a>)))
           (<a id='3301' tid='3302' class='u'>delete-char</a> <a id='3303' tid='3304' class='u'>1</a>))
          ((<a id='3305' tid='3306' class='u'>eq</a> (<a id='3307' tid='3308' class='u'>1-</a> (<a id='3309' tid='3310' class='u'>point</a>)) (<a id='3311' tid='3312' class='u'>car</a> <a id='3313' tid='3314' class='u'>start+end</a>))
           <a id='3315' tid='3316' class='u'>;; If it is the close-quote, delete only if we&#39;re also right
</a>           <a id='3317' tid='3318' class='u'>;; past the open-quote (i.e. it&#39;s empty), and then delete
</a>           <a id='3319' tid='3320' class='u'>;; both quotes.  Otherwise we refuse to delete it.
</a>           (<a id='3321' tid='3322' class='u'>backward-delete-char</a> <a id='3323' tid='3324' class='u'>1</a>)
           (<a id='3325' tid='3326' class='u'>delete-char</a> <a id='3327' tid='3328' class='u'>1</a>)))))

(<a id='2107' tid='2108' class='u'>defun</a> <a id='2109' tid='2110' class='u'>paredit-backward-delete</a> (<a id='2111' tid='2112' class='u'>&optional</a> <a id='2113' tid='2114' class='u'>argument</a>)
  <a id='2115' tid='2116' class='u'>&quot;Delete a character backward or move backward over a delimiter.
If on a closing S-expression delimiter, move backward into the
  S-expression.
If on an opening S-expression delimiter, refuse to delete unless the
  S-expression is empty, in which case delete the whole S-expression.
With a numeric prefix argument N, delete N characters backward.
With a `C-u&#39; prefix argument, simply delete a character backward,
  without regard for delimiter balancing.&quot;</a>
  (<a id='2117' tid='2118' class='u'>interactive</a> <a id='2119' tid='2120' class='u'>&quot;P&quot;</a>)
  (<span class='d'>cond</span> ((<a id='1249' tid='1250' class='m'>or</a> (<a id='1251' tid='1252' class='m'>consp</a> <a id='1253' tid='1254' class='m'>argument</a>) (<a id='1255' tid='1256' class='m'>bobp</a>))
         <a id='1257' tid='1258' class='m'>;++ Should this untabify?
</a>         (<a id='1259' tid='1260' class='m'>backward-delete-char</a> <a id='1261' tid='1262' class='m'>1</a>))
        ((<a id='611' tid='612' class='m'>integerp</a> <a id='613' tid='614' class='m'>argument</a>)
         (<a id='615' tid='616' class='m'>if</a> (<a id='617' tid='618' class='m'>&lt;</a> <a id='619' tid='620' class='m'>argument</a> <a id='621' tid='622' class='m'>0</a>)
             (<a id='623' tid='624' class='m'>paredit-forward-delete</a> (<a id='625' tid='626' class='m'>-</a> <a id='627' tid='628' class='m'>0</a> <a id='629' tid='630' class='m'>argument</a>))
             (<a id='631' tid='632' class='m'>while</a> (<a id='633' tid='634' class='m'>&gt;</a> <a id='635' tid='636' class='m'>argument</a> <a id='637' tid='638' class='m'>0</a>)
               (<a id='639' tid='640' class='m'>paredit-backward-delete</a>)
               (<a id='641' tid='642' class='m'>setq</a> <a id='643' tid='644' class='m'>argument</a> (<a id='645' tid='646' class='m'>-</a> <a id='647' tid='648' class='m'>argument</a> <a id='649' tid='650' class='m'>1</a>)))))
        <span class='d'>((paredit-in-string-p)
         (paredit-backward-delete-in-string))</span>
        <span class='d'>((paredit-in-comment-p)
         (backward-delete-char 1))</span>
        ((<a id='483' tid='484' class='m'>paredit-in-char-p</a>)            <a id='485' tid='486' class='m'>; Escape -- delete both chars.
</a>         (<a id='487' tid='488' class='m'>backward-delete-char</a> <a id='489' tid='490' class='m'>1</a>)
         (<a id='491' tid='492' class='m'>delete-char</a> <a id='493' tid='494' class='m'>1</a>))
        ((<a id='449' tid='450' class='m'>paredit-in-char-p</a> (<a id='451' tid='452' class='m'>1-</a> (<a id='453' tid='454' class='m'>point</a>)))
         (<a id='455' tid='456' class='m'>backward-delete-char</a> <a id='457' tid='458' class='m'>2</a>))      <span class='d'>; ditto
</span>        ((<a id='379' tid='380' class='m'>let</a> ((<a id='381' tid='382' class='m'>syn</a> (<a id='383' tid='384' class='m'>char-syntax</a> (<a id='385' tid='386' class='m'>char-before</a>))))
           (<a id='387' tid='388' class='m'>or</a> (<a id='389' tid='390' class='m'>eq</a> <a id='391' tid='392' class='m'>syn</a> <a id='393' tid='394' class='m'>?\)</a> )
               (<a id='395' tid='396' class='m'>eq</a> <a id='397' tid='398' class='m'>syn</a> <a id='399' tid='400' class='m'>?\&quot;</a> )))
         (<a id='401' tid='402' class='m'>if</a> (<a id='403' tid='404' class='m'>save-excursion</a>
               (<a id='405' tid='406' class='m'>paredit-handle-sexp-errors</a> (<a id='407' tid='408' class='m'>progn</a> (<a id='409' tid='410' class='m'>backward-sexp</a>) <a id='411' tid='412' class='m'>t</a>)
                 <a id='413' tid='414' class='m'>nil</a>))
             (<a id='415' tid='416' class='m'>backward-char</a>)
           (<a id='417' tid='418' class='m'>message</a> <a id='419' tid='420' class='m'>&quot;Deleting spurious closing delimiter.&quot;</a>)
           (<a id='421' tid='422' class='m'>backward-delete-char</a> <a id='423' tid='424' class='m'>1</a>)))
        ((<a id='287' tid='288' class='m'>and</a> (<a id='289' tid='290' class='m'>eq</a> (<a id='291' tid='292' class='m'>char-syntax</a> (<a id='293' tid='294' class='m'>char-before</a>)) <a id='295' tid='296' class='m'>?\(</a> )
              (<a id='297' tid='298' class='m'>eq</a> (<a id='299' tid='300' class='m'>char-after</a>) (<a id='301' tid='302' class='m'>matching-paren</a> (<a id='303' tid='304' class='m'>char-before</a>))))
         (<a id='305' tid='306' class='m'>backward-delete-char</a> <a id='307' tid='308' class='m'>1</a>)       <a id='309' tid='310' class='m'>; Empty list -- delete both
</a>         (<a id='311' tid='312' class='m'>delete-char</a> <a id='313' tid='314' class='m'>1</a>))               <span class='d'>;   delimiters.
</span>        <span class='d'>;; Delete it, unless it&#39;s an opening delimiter.  The case of
</span>        <span class='d'>;; character literals is already handled by now.
</span>        ((<a id='211' tid='212' class='m'>not</a> (<a id='213' tid='214' class='m'>eq</a> (<a id='215' tid='216' class='m'>char-syntax</a> (<a id='217' tid='218' class='m'>char-before</a>)) <a id='219' tid='220' class='m'>?\(</a> ))
         (<a id='221' tid='222' class='m'>backward-delete-char-untabify</a> <a id='223' tid='224' class='m'>1</a>))))

(<a id='2121' tid='2122' class='u'>defun</a> <a id='2123' tid='2124' class='u'>paredit-backward-delete-in-string</a> ()
  (<a id='2125' tid='2126' class='u'>let</a> ((<a id='2127' tid='2128' class='u'>start+end</a> (<a id='2129' tid='2130' class='u'>paredit-string-start+end-points</a>)))
    (<a id='2131' tid='2132' class='u'>cond</a> ((<a id='2133' tid='2134' class='u'>not</a> (<a id='2135' tid='2136' class='u'>eq</a> (<a id='2137' tid='2138' class='u'>1-</a> (<a id='2139' tid='2140' class='u'>point</a>)) (<a id='2141' tid='2142' class='u'>car</a> <a id='2143' tid='2144' class='u'>start+end</a>)))
           <a id='2145' tid='2146' class='u'>;; If it&#39;s not the open-quote, it&#39;s safe to delete.
</a>           (<a id='2147' tid='2148' class='u'>if</a> (<a id='2149' tid='2150' class='u'>paredit-in-string-escape-p</a>)
               <a id='2151' tid='2152' class='u'>;; If we&#39;re on a string escape, since we&#39;re about to
</a>               <a id='2153' tid='2154' class='u'>;; delete the backslash, we must first delete the
</a>               <a id='2155' tid='2156' class='u'>;; escaped char.
</a>               (<a id='2157' tid='2158' class='u'>delete-char</a> <a id='2159' tid='2160' class='u'>1</a>))
           (<a id='2161' tid='2162' class='u'>backward-delete-char</a> <a id='2163' tid='2164' class='u'>1</a>)
           (<a id='2165' tid='2166' class='u'>if</a> (<a id='2167' tid='2168' class='u'>paredit-in-string-escape-p</a>)
               <a id='2169' tid='2170' class='u'>;; If, after deleting a character, we find ourselves in
</a>               <a id='2171' tid='2172' class='u'>;; a string escape, we must have deleted the escaped
</a>               <a id='2173' tid='2174' class='u'>;; character, and the backslash is behind the point, so
</a>               <a id='2175' tid='2176' class='u'>;; backward delete it.
</a>               (<a id='2177' tid='2178' class='u'>backward-delete-char</a> <a id='2179' tid='2180' class='u'>1</a>)))
          ((<a id='2181' tid='2182' class='u'>eq</a> (<a id='2183' tid='2184' class='u'>point</a>) (<a id='2185' tid='2186' class='u'>cdr</a> <a id='2187' tid='2188' class='u'>start+end</a>))
           <a id='2189' tid='2190' class='u'>;; If it is the open-quote, delete only if we&#39;re also right
</a>           <a id='2191' tid='2192' class='u'>;; past the close-quote (i.e. it&#39;s empty), and then delete
</a>           <a id='2193' tid='2194' class='u'>;; both quotes.  Otherwise we refuse to delete it.
</a>           (<a id='2195' tid='2196' class='u'>backward-delete-char</a> <a id='2197' tid='2198' class='u'>1</a>)
           (<a id='2199' tid='2200' class='u'>delete-char</a> <a id='2201' tid='2202' class='u'>1</a>)))))

<a id='7345' tid='7346' class='u'>;;;; Killing
</a>
(<a id='4551' tid='4552' class='u'>defun</a> <a id='4553' tid='4554' class='u'>paredit-kill</a> (<a id='4555' tid='4556' class='u'>&optional</a> <a id='4557' tid='4558' class='u'>argument</a>)
  <a id='4559' tid='4560' class='u'>&quot;Kill a line as if with `kill-line&#39;, but respecting delimiters.
In a string, act exactly as `kill-line&#39; but do not kill past the
  closing string delimiter.
On a line with no S-expressions on it starting after the point or
  within a comment, act exactly as `kill-line&#39;.
Otherwise, kill all S-expressions that start after the point.
With a `C-u&#39; prefix argument, just do the standard `kill-line&#39;.
With a numeric prefix argument N, do `kill-line&#39; that many times.&quot;</a>
  (<a id='4561' tid='4562' class='u'>interactive</a> <a id='4563' tid='4564' class='u'>&quot;P&quot;</a>)
  (<span class='d'>cond</span> (<a id='1263' tid='1264' class='m'>argument</a>
         (<a id='1265' tid='1266' class='m'>kill-line</a> (<a id='1267' tid='1268' class='m'>if</a> (<a id='1269' tid='1270' class='m'>integerp</a> <a id='1271' tid='1272' class='m'>argument</a>) <a id='1273' tid='1274' class='m'>argument</a> <a id='1275' tid='1276' class='m'>1</a>)))
        <span class='d'>((paredit-in-string-p)
         (paredit-kill-line-in-string))</span>
        <span class='d'>((paredit-in-comment-p)
         (kill-line))</span>
        ((<a id='651' tid='652' class='m'>save-excursion</a> (<a id='653' tid='654' class='m'>paredit-skip-whitespace</a> <a id='655' tid='656' class='m'>t</a> (<a id='657' tid='658' class='m'>point-at-eol</a>))
                         (<a id='659' tid='660' class='m'>or</a> (<a id='661' tid='662' class='m'>eolp</a>) (<a id='663' tid='664' class='m'>eq</a> (<a id='665' tid='666' class='m'>char-after</a>) <a id='667' tid='668' class='m'>?\;</a> )))
         <a id='669' tid='670' class='m'>;** Be careful about trailing backslashes.
</a>         (<a id='671' tid='672' class='m'>if</a> (<a id='673' tid='674' class='m'>paredit-in-char-p</a>)
             (<a id='675' tid='676' class='m'>backward-char</a>))
         (<a id='677' tid='678' class='m'>kill-line</a>))
        <span class='d'>(t (paredit-kill-sexps-on-line))</span>))

(<a id='4565' tid='4566' class='u'>defun</a> <a id='4567' tid='4568' class='u'>paredit-kill-line-in-string</a> ()
  (<a id='4569' tid='4570' class='u'>if</a> (<a id='4571' tid='4572' class='u'>save-excursion</a> (<a id='4573' tid='4574' class='u'>paredit-skip-whitespace</a> <a id='4575' tid='4576' class='u'>t</a> (<a id='4577' tid='4578' class='u'>point-at-eol</a>))
                      (<a id='4579' tid='4580' class='u'>eolp</a>))
      (<a id='4581' tid='4582' class='u'>kill-line</a>)
    (<a id='4583' tid='4584' class='u'>save-excursion</a>
      <a id='4585' tid='4586' class='u'>;; Be careful not to split an escape sequence.
</a>      (<a id='4587' tid='4588' class='u'>if</a> (<a id='4589' tid='4590' class='u'>paredit-in-string-escape-p</a>)
          (<a id='4591' tid='4592' class='u'>backward-char</a>))
      (<a id='4593' tid='4594' class='u'>kill-region</a> (<a id='4595' tid='4596' class='u'>point</a>)
                   (<a id='4597' tid='4598' class='u'>min</a> (<a id='4599' tid='4600' class='u'>point-at-eol</a>)
                        (<a id='4601' tid='4602' class='u'>cdr</a> (<a id='4603' tid='4604' class='u'>paredit-string-start+end-points</a>)))))))

(<a id='4621' tid='4622' class='u'>defun</a> <a id='4623' tid='4624' class='u'>paredit-kill-sexps-on-line</a> ()
  (<a id='4625' tid='4626' class='u'>if</a> (<a id='4627' tid='4628' class='u'>paredit-in-char-p</a>)               <a id='4629' tid='4630' class='u'>; Move past the \ and prefix.
</a>      (<a id='4631' tid='4632' class='u'>backward-char</a> <a id='4633' tid='4634' class='u'>2</a>))                <a id='4635' tid='4636' class='u'>; (# in Scheme/CL, ? in elisp)
</a>  (<a id='4637' tid='4638' class='u'>let</a> ((<a id='4639' tid='4640' class='u'>beginning</a> (<a id='4641' tid='4642' class='u'>point</a>))
        (<a id='4643' tid='4644' class='u'>eol</a> (<a id='4645' tid='4646' class='u'>point-at-eol</a>)))
    (<a id='4647' tid='4648' class='u'>let</a> ((<a id='4649' tid='4650' class='u'>end-of-list-p</a> (<a id='4651' tid='4652' class='u'>paredit-forward-sexps-to-kill</a> <a id='4653' tid='4654' class='u'>beginning</a> <a id='4655' tid='4656' class='u'>eol</a>)))
      <a id='4657' tid='4658' class='u'>;; If we got to the end of the list and it&#39;s on the same line,
</a>      <a id='4659' tid='4660' class='u'>;; move backward past the closing delimiter before killing.  (This
</a>      <a id='4661' tid='4662' class='u'>;; allows something like killing the whitespace in (    ).)
</a>      (<a id='4663' tid='4664' class='u'>if</a> <a id='4665' tid='4666' class='u'>end-of-list-p</a> (<a id='4667' tid='4668' class='u'>progn</a> (<a id='4669' tid='4670' class='u'>up-list</a>) (<a id='4671' tid='4672' class='u'>backward-char</a>)))
      (<a id='4673' tid='4674' class='u'>if</a> <a id='4675' tid='4676' class='u'>kill-whole-line</a>
          (<a id='4677' tid='4678' class='u'>paredit-kill-sexps-on-whole-line</a> <a id='4679' tid='4680' class='u'>beginning</a>)
        (<a id='4681' tid='4682' class='u'>kill-region</a> <a id='4683' tid='4684' class='u'>beginning</a>
                     <a id='4685' tid='4686' class='u'>;; If all of the S-expressions were on one line,
</a>                     <a id='4687' tid='4688' class='u'>;; i.e. we&#39;re still on that line after moving past
</a>                     <a id='4689' tid='4690' class='u'>;; the last one, kill the whole line, including
</a>                     <a id='4691' tid='4692' class='u'>;; any comments; otherwise just kill to the end of
</a>                     <a id='4693' tid='4694' class='u'>;; the last S-expression we found.  Be sure,
</a>                     <a id='4695' tid='4696' class='u'>;; though, not to kill any closing parentheses.
</a>                     (<a id='4697' tid='4698' class='u'>if</a> (<a id='4699' tid='4700' class='u'>and</a> (<a id='4701' tid='4702' class='u'>not</a> <a id='4703' tid='4704' class='u'>end-of-list-p</a>)
                              (<a id='4705' tid='4706' class='u'>eq</a> (<a id='4707' tid='4708' class='u'>point-at-eol</a>) <a id='4709' tid='4710' class='u'>eol</a>))
                         <a id='4711' tid='4712' class='u'>eol</a>
                         (<a id='4713' tid='4714' class='u'>point</a>)))))))

<a id='7347' tid='7348' class='u'>;;; Please do not try to understand this code unless you have a VERY
</a><a id='7349' tid='7350' class='u'>;;; good reason to do so.  I gave up trying to figure it out well
</a><a id='7351' tid='7352' class='u'>;;; enough to explain it, long ago.
</a>
(<a id='3647' tid='3648' class='u'>defun</a> <a id='3649' tid='3650' class='u'>paredit-forward-sexps-to-kill</a> (<a id='3651' tid='3652' class='u'>beginning</a> <a id='3653' tid='3654' class='u'>eol</a>)
  (<a id='3655' tid='3656' class='u'>let</a> ((<a id='3657' tid='3658' class='u'>end-of-list-p</a> <a id='3659' tid='3660' class='u'>nil</a>)
        (<a id='3661' tid='3662' class='u'>firstp</a> <a id='3663' tid='3664' class='u'>t</a>))
    <a id='3665' tid='3666' class='u'>;; Move to the end of the last S-expression that started on this
</a>    <a id='3667' tid='3668' class='u'>;; line, or to the closing delimiter if the last S-expression in
</a>    <a id='3669' tid='3670' class='u'>;; this list is on the line.
</a>    (<a id='3671' tid='3672' class='u'>catch</a> <a id='3673' tid='3674' class='u'>&#39;</a><a id='3675' tid='3676' class='u'>return</a>
      (<a id='3677' tid='3678' class='u'>while</a> <a id='3679' tid='3680' class='u'>t</a>
        <a id='3681' tid='3682' class='u'>;; This and the `kill-whole-line&#39; business below fix a bug that
</a>        <a id='3683' tid='3684' class='u'>;; inhibited any S-expression at the very end of the buffer
</a>        <a id='3685' tid='3686' class='u'>;; (with no trailing newline) from being deleted.  It&#39;s a
</a>        <a id='3687' tid='3688' class='u'>;; bizarre fix that I ought to document at some point, but I am
</a>        <a id='3689' tid='3690' class='u'>;; too busy at the moment to do so.
</a>        (<a id='3691' tid='3692' class='u'>if</a> (<a id='3693' tid='3694' class='u'>and</a> <a id='3695' tid='3696' class='u'>kill-whole-line</a> (<a id='3697' tid='3698' class='u'>eobp</a>)) (<a id='3699' tid='3700' class='u'>throw</a> <a id='3701' tid='3702' class='u'>&#39;</a><a id='3703' tid='3704' class='u'>return</a> <a id='3705' tid='3706' class='u'>nil</a>))
        (<a id='3707' tid='3708' class='u'>save-excursion</a>
          (<a id='3709' tid='3710' class='u'>paredit-handle-sexp-errors</a> (<a id='3711' tid='3712' class='u'>forward-sexp</a>)
            (<a id='3713' tid='3714' class='u'>up-list</a>)
            (<a id='3715' tid='3716' class='u'>setq</a> <a id='3717' tid='3718' class='u'>end-of-list-p</a> (<a id='3719' tid='3720' class='u'>eq</a> (<a id='3721' tid='3722' class='u'>point-at-eol</a>) <a id='3723' tid='3724' class='u'>eol</a>))
            (<a id='3725' tid='3726' class='u'>throw</a> <a id='3727' tid='3728' class='u'>&#39;</a><a id='3729' tid='3730' class='u'>return</a> <a id='3731' tid='3732' class='u'>nil</a>))
          (<a id='3733' tid='3734' class='u'>if</a> (<a id='3735' tid='3736' class='u'>or</a> (<a id='3737' tid='3738' class='u'>and</a> (<a id='3739' tid='3740' class='u'>not</a> <a id='3741' tid='3742' class='u'>firstp</a>)
                       (<a id='3743' tid='3744' class='u'>not</a> <a id='3745' tid='3746' class='u'>kill-whole-line</a>)
                       (<a id='3747' tid='3748' class='u'>eobp</a>))
                  (<a id='3749' tid='3750' class='u'>paredit-handle-sexp-errors</a>
                      (<a id='3751' tid='3752' class='u'>progn</a> (<a id='3753' tid='3754' class='u'>backward-sexp</a>) <a id='3755' tid='3756' class='u'>nil</a>)
                    <a id='3757' tid='3758' class='u'>t</a>)
                  (<a id='3759' tid='3760' class='u'>not</a> (<a id='3761' tid='3762' class='u'>eq</a> (<a id='3763' tid='3764' class='u'>point-at-eol</a>) <a id='3765' tid='3766' class='u'>eol</a>)))
              (<a id='3767' tid='3768' class='u'>throw</a> <a id='3769' tid='3770' class='u'>&#39;</a><a id='3771' tid='3772' class='u'>return</a> <a id='3773' tid='3774' class='u'>nil</a>)))
        (<a id='3775' tid='3776' class='u'>forward-sexp</a>)
        (<a id='3777' tid='3778' class='u'>if</a> (<a id='3779' tid='3780' class='u'>and</a> <a id='3781' tid='3782' class='u'>firstp</a>
                 (<a id='3783' tid='3784' class='u'>not</a> <a id='3785' tid='3786' class='u'>kill-whole-line</a>)
                 (<a id='3787' tid='3788' class='u'>eobp</a>))
            (<a id='3789' tid='3790' class='u'>throw</a> <a id='3791' tid='3792' class='u'>&#39;</a><a id='3793' tid='3794' class='u'>return</a> <a id='3795' tid='3796' class='u'>nil</a>))
        (<a id='3797' tid='3798' class='u'>setq</a> <a id='3799' tid='3800' class='u'>firstp</a> <a id='3801' tid='3802' class='u'>nil</a>)))
    <a id='3803' tid='3804' class='u'>end-of-list-p</a>))

(<a id='4715' tid='4716' class='u'>defun</a> <a id='4717' tid='4718' class='u'>paredit-kill-sexps-on-whole-line</a> (<a id='4719' tid='4720' class='u'>beginning</a>)
  (<a id='4721' tid='4722' class='u'>kill-region</a> <a id='4723' tid='4724' class='u'>beginning</a>
               (<a id='4725' tid='4726' class='u'>or</a> (<a id='4727' tid='4728' class='u'>save-excursion</a>     <a id='4729' tid='4730' class='u'>; Delete trailing indentation...
</a>                     (<a id='4731' tid='4732' class='u'>paredit-skip-whitespace</a> <a id='4733' tid='4734' class='u'>t</a>)
                     (<a id='4735' tid='4736' class='u'>and</a> (<a id='4737' tid='4738' class='u'>not</a> (<a id='4739' tid='4740' class='u'>eq</a> (<a id='4741' tid='4742' class='u'>char-after</a>) <a id='4743' tid='4744' class='u'>?\;</a> ))
                          (<a id='4745' tid='4746' class='u'>point</a>)))
                   <a id='4747' tid='4748' class='u'>;; ...or just use the point past the newline, if
</a>                   <a id='4749' tid='4750' class='u'>;; we encounter a comment.
</a>                   (<a id='4751' tid='4752' class='u'>point-at-eol</a>)))
  (<a id='4753' tid='4754' class='u'>cond</a> ((<a id='4755' tid='4756' class='u'>save-excursion</a> (<a id='4757' tid='4758' class='u'>paredit-skip-whitespace</a> <a id='4759' tid='4760' class='u'>nil</a> (<a id='4761' tid='4762' class='u'>point-at-bol</a>))
                         (<a id='4763' tid='4764' class='u'>bolp</a>))
         <a id='4765' tid='4766' class='u'>;; Nothing but indentation before the point, so indent it.
</a>         (<a id='4767' tid='4768' class='u'>lisp-indent-line</a>))
        ((<a id='4769' tid='4770' class='u'>eobp</a>) <a id='4771' tid='4772' class='u'>nil</a>)       <a id='4773' tid='4774' class='u'>; Protect the CHAR-SYNTAX below against NIL.
</a>        <a id='4775' tid='4776' class='u'>;; Insert a space to avoid invalid joining if necessary.
</a>        ((<a id='4777' tid='4778' class='u'>let</a> ((<a id='4779' tid='4780' class='u'>syn-before</a> (<a id='4781' tid='4782' class='u'>char-syntax</a> (<a id='4783' tid='4784' class='u'>char-before</a>)))
               (<a id='4785' tid='4786' class='u'>syn-after</a>  (<a id='4787' tid='4788' class='u'>char-syntax</a> (<a id='4789' tid='4790' class='u'>char-after</a>))))
           (<a id='4791' tid='4792' class='u'>or</a> (<a id='4793' tid='4794' class='u'>and</a> (<a id='4795' tid='4796' class='u'>eq</a> <a id='4797' tid='4798' class='u'>syn-before</a> <a id='4799' tid='4800' class='u'>?\)</a> )            <a id='4801' tid='4802' class='u'>; Separate opposing
</a>                    (<a id='4803' tid='4804' class='u'>eq</a> <a id='4805' tid='4806' class='u'>syn-after</a>  <a id='4807' tid='4808' class='u'>?\(</a> ))           <a id='4809' tid='4810' class='u'>;   parentheses,
</a>               (<a id='4811' tid='4812' class='u'>and</a> (<a id='4813' tid='4814' class='u'>eq</a> <a id='4815' tid='4816' class='u'>syn-before</a> <a id='4817' tid='4818' class='u'>?\&quot;</a> )            <a id='4819' tid='4820' class='u'>; string delimiter
</a>                    (<a id='4821' tid='4822' class='u'>eq</a> <a id='4823' tid='4824' class='u'>syn-after</a>  <a id='4825' tid='4826' class='u'>?\&quot;</a> ))           <a id='4827' tid='4828' class='u'>;   pairs,
</a>               (<a id='4829' tid='4830' class='u'>and</a> (<a id='4831' tid='4832' class='u'>memq</a> <a id='4833' tid='4834' class='u'>syn-before</a> <a id='4835' tid='4836' class='u'>&#39;</a>(<a id='4837' tid='4838' class='u'>?_</a> <a id='4839' tid='4840' class='u'>?w</a>))      <a id='4841' tid='4842' class='u'>; or word or symbol
</a>                    (<a id='4843' tid='4844' class='u'>memq</a> <a id='4845' tid='4846' class='u'>syn-after</a>  <a id='4847' tid='4848' class='u'>&#39;</a>(<a id='4849' tid='4850' class='u'>?_</a> <a id='4851' tid='4852' class='u'>?w</a>)))))   <a id='4853' tid='4854' class='u'>;   constituents.
</a>         (<a id='4855' tid='4856' class='u'>insert</a> <a id='4857' tid='4858' class='u'>&quot; &quot;</a>))))

<a id='7353' tid='7354' class='u'>;;;;; Killing Words
</a>
<a id='7355' tid='7356' class='u'>;;; This is tricky and asymmetrical because backward parsing is
</a><a id='7357' tid='7358' class='u'>;;; extraordinarily difficult or impossible, so we have to implement
</a><a id='7359' tid='7360' class='u'>;;; killing in both directions by parsing forward.
</a>
(<a id='3517' tid='3518' class='u'>defun</a> <a id='3519' tid='3520' class='u'>paredit-forward-kill-word</a> ()
  <a id='3521' tid='3522' class='u'>&quot;Kill a word forward, skipping over intervening delimiters.&quot;</a>
  (<a id='3523' tid='3524' class='u'>interactive</a>)
  (<a id='3525' tid='3526' class='u'>let</a> ((<a id='3527' tid='3528' class='u'>beginning</a> (<a id='3529' tid='3530' class='u'>point</a>)))
    (<a id='3531' tid='3532' class='u'>skip-syntax-forward</a> <a id='3533' tid='3534' class='u'>&quot; -&quot;</a>)
    (<a id='3535' tid='3536' class='u'>let*</a> ((<a id='3537' tid='3538' class='u'>parse-state</a> (<a id='3539' tid='3540' class='u'>paredit-current-parse-state</a>))
           (<a id='3541' tid='3542' class='u'>state</a> (<a id='3543' tid='3544' class='u'>paredit-kill-word-state</a> <a id='3545' tid='3546' class='u'>parse-state</a> <a id='3547' tid='3548' class='u'>&#39;</a><a id='3549' tid='3550' class='u'>char-after</a>)))
      (<a id='3551' tid='3552' class='u'>while</a> (<a id='3553' tid='3554' class='u'>not</a> (<a id='3555' tid='3556' class='u'>or</a> (<a id='3557' tid='3558' class='u'>eobp</a>)
                      (<a id='3559' tid='3560' class='u'>eq</a> <a id='3561' tid='3562' class='u'>?w</a> (<a id='3563' tid='3564' class='u'>char-syntax</a> (<a id='3565' tid='3566' class='u'>char-after</a>)))))
        (<a id='3567' tid='3568' class='u'>setq</a> <a id='3569' tid='3570' class='u'>parse-state</a>
              (<a id='3571' tid='3572' class='u'>progn</a> (<a id='3573' tid='3574' class='u'>forward-char</a> <a id='3575' tid='3576' class='u'>1</a>) (<a id='3577' tid='3578' class='u'>paredit-current-parse-state</a>))
<a id='3579' tid='3580' class='u'>;;               (parse-partial-sexp (point) (1+ (point))
</a><a id='3581' tid='3582' class='u'>;;                                   nil nil parse-state)
</a>              )
        (<a id='3583' tid='3584' class='u'>let*</a> ((<a id='3585' tid='3586' class='u'>old-state</a> <a id='3587' tid='3588' class='u'>state</a>)
               (<a id='3589' tid='3590' class='u'>new-state</a>
                (<a id='3591' tid='3592' class='u'>paredit-kill-word-state</a> <a id='3593' tid='3594' class='u'>parse-state</a> <a id='3595' tid='3596' class='u'>&#39;</a><a id='3597' tid='3598' class='u'>char-after</a>)))
          (<a id='3599' tid='3600' class='u'>cond</a> ((<a id='3601' tid='3602' class='u'>not</a> (<a id='3603' tid='3604' class='u'>eq</a> <a id='3605' tid='3606' class='u'>old-state</a> <a id='3607' tid='3608' class='u'>new-state</a>))
                 (<a id='3609' tid='3610' class='u'>setq</a> <a id='3611' tid='3612' class='u'>parse-state</a>
                       (<a id='3613' tid='3614' class='u'>paredit-kill-word-hack</a> <a id='3615' tid='3616' class='u'>old-state</a>
                                               <a id='3617' tid='3618' class='u'>new-state</a>
                                               <a id='3619' tid='3620' class='u'>parse-state</a>))
                 (<a id='3621' tid='3622' class='u'>setq</a> <a id='3623' tid='3624' class='u'>state</a>
                       (<a id='3625' tid='3626' class='u'>paredit-kill-word-state</a> <a id='3627' tid='3628' class='u'>parse-state</a>
                                                <a id='3629' tid='3630' class='u'>&#39;</a><a id='3631' tid='3632' class='u'>char-after</a>))
                 (<a id='3633' tid='3634' class='u'>setq</a> <a id='3635' tid='3636' class='u'>beginning</a> (<a id='3637' tid='3638' class='u'>point</a>)))))))
    (<a id='3639' tid='3640' class='u'>goto-char</a> <a id='3641' tid='3642' class='u'>beginning</a>)
    (<a id='3643' tid='3644' class='u'>kill-word</a> <a id='3645' tid='3646' class='u'>1</a>)))

(<a id='2245' tid='2246' class='u'>defun</a> <a id='2247' tid='2248' class='u'>paredit-backward-kill-word</a> ()
  <a id='2249' tid='2250' class='u'>&quot;Kill a word backward, skipping over any intervening delimiters.&quot;</a>
  (<a id='2251' tid='2252' class='u'>interactive</a>)
  (<a id='2253' tid='2254' class='u'>if</a> (<a id='2255' tid='2256' class='u'>not</a> (<a id='2257' tid='2258' class='u'>or</a> (<a id='2259' tid='2260' class='u'>bobp</a>)
               (<a id='2261' tid='2262' class='u'>eq</a> (<a id='2263' tid='2264' class='u'>char-syntax</a> (<a id='2265' tid='2266' class='u'>char-before</a>)) <a id='2267' tid='2268' class='u'>?w</a>)))
      (<a id='2269' tid='2270' class='u'>let</a> ((<a id='2271' tid='2272' class='u'>end</a> (<a id='2273' tid='2274' class='u'>point</a>)))
        (<a id='2275' tid='2276' class='u'>backward-word</a> <a id='2277' tid='2278' class='u'>1</a>)
        (<a id='2279' tid='2280' class='u'>forward-word</a> <a id='2281' tid='2282' class='u'>1</a>)
        (<a id='2283' tid='2284' class='u'>goto-char</a> (<a id='2285' tid='2286' class='u'>min</a> <a id='2287' tid='2288' class='u'>end</a> (<a id='2289' tid='2290' class='u'>point</a>)))
        (<a id='2291' tid='2292' class='u'>let*</a> ((<a id='2293' tid='2294' class='u'>parse-state</a> (<a id='2295' tid='2296' class='u'>paredit-current-parse-state</a>))
               (<a id='2297' tid='2298' class='u'>state</a>
                (<a id='2299' tid='2300' class='u'>paredit-kill-word-state</a> <a id='2301' tid='2302' class='u'>parse-state</a> <a id='2303' tid='2304' class='u'>&#39;</a><a id='2305' tid='2306' class='u'>char-before</a>)))
          (<a id='2307' tid='2308' class='u'>while</a> (<a id='2309' tid='2310' class='u'>and</a> (<a id='2311' tid='2312' class='u'>&lt;</a> (<a id='2313' tid='2314' class='u'>point</a>) <a id='2315' tid='2316' class='u'>end</a>)
                      (<a id='2317' tid='2318' class='u'>progn</a>
                        (<a id='2319' tid='2320' class='u'>setq</a> <a id='2321' tid='2322' class='u'>parse-state</a>
                              (<a id='2323' tid='2324' class='u'>parse-partial-sexp</a> (<a id='2325' tid='2326' class='u'>point</a>) (<a id='2327' tid='2328' class='u'>1+</a> (<a id='2329' tid='2330' class='u'>point</a>))
                                                  <a id='2331' tid='2332' class='u'>nil</a> <a id='2333' tid='2334' class='u'>nil</a> <a id='2335' tid='2336' class='u'>parse-state</a>))
                        (<a id='2337' tid='2338' class='u'>or</a> (<a id='2339' tid='2340' class='u'>eq</a> <a id='2341' tid='2342' class='u'>state</a>
                                (<a id='2343' tid='2344' class='u'>paredit-kill-word-state</a> <a id='2345' tid='2346' class='u'>parse-state</a>
                                                         <a id='2347' tid='2348' class='u'>&#39;</a><a id='2349' tid='2350' class='u'>char-before</a>))
                            (<a id='2351' tid='2352' class='u'>progn</a> (<a id='2353' tid='2354' class='u'>backward-char</a> <a id='2355' tid='2356' class='u'>1</a>) <a id='2357' tid='2358' class='u'>nil</a>)))))
          (<a id='2359' tid='2360' class='u'>if</a> (<a id='2361' tid='2362' class='u'>and</a> (<a id='2363' tid='2364' class='u'>eq</a> <a id='2365' tid='2366' class='u'>state</a> <a id='2367' tid='2368' class='u'>&#39;</a><a id='2369' tid='2370' class='u'>comment</a>)
                   (<a id='2371' tid='2372' class='u'>eq</a> <a id='2373' tid='2374' class='u'>?\#</a> (<a id='2375' tid='2376' class='u'>char-after</a> (<a id='2377' tid='2378' class='u'>point</a>)))
                   (<a id='2379' tid='2380' class='u'>eq</a> <a id='2381' tid='2382' class='u'>?\|</a> (<a id='2383' tid='2384' class='u'>char-before</a> (<a id='2385' tid='2386' class='u'>point</a>))))
              (<a id='2387' tid='2388' class='u'>backward-char</a> <a id='2389' tid='2390' class='u'>1</a>)))))
  (<a id='2391' tid='2392' class='u'>backward-kill-word</a> <a id='2393' tid='2394' class='u'>1</a>))

<a id='7361' tid='7362' class='u'>;;;;;; Word-Killing Auxiliaries
</a>
(<a id='5135' tid='5136' class='u'>defun</a> <a id='5137' tid='5138' class='u'>paredit-kill-word-state</a> (<a id='5139' tid='5140' class='u'>parse-state</a> <a id='5141' tid='5142' class='u'>adjacent-char-fn</a>)
  (<a id='5143' tid='5144' class='u'>cond</a> ((<a id='5145' tid='5146' class='u'>paredit-in-comment-p</a> <a id='5147' tid='5148' class='u'>parse-state</a>) <a id='5149' tid='5150' class='u'>&#39;</a><a id='5151' tid='5152' class='u'>comment</a>)
        ((<a id='5153' tid='5154' class='u'>paredit-in-string-p</a>  <a id='5155' tid='5156' class='u'>parse-state</a>) <a id='5157' tid='5158' class='u'>&#39;</a><a id='5159' tid='5160' class='u'>string</a>)
        ((<a id='5161' tid='5162' class='u'>memq</a> (<a id='5163' tid='5164' class='u'>char-syntax</a> (<a id='5165' tid='5166' class='u'>funcall</a> <a id='5167' tid='5168' class='u'>adjacent-char-fn</a>))
               <a id='5169' tid='5170' class='u'>&#39;</a>(<a id='5171' tid='5172' class='u'>?\(</a> <a id='5173' tid='5174' class='u'>?\)</a> ))
         <a id='5175' tid='5176' class='u'>&#39;</a><a id='5177' tid='5178' class='u'>delimiter</a>)
        (<a id='5179' tid='5180' class='u'>t</a> <a id='5181' tid='5182' class='u'>&#39;</a><a id='5183' tid='5184' class='u'>other</a>)))

<a id='7363' tid='7364' class='u'>;;; This optionally advances the point past any comment delimiters that
</a><a id='7365' tid='7366' class='u'>;;; should probably not be touched, based on the last state change and
</a><a id='7367' tid='7368' class='u'>;;; the characters around the point.  It returns a new parse state,
</a><a id='7369' tid='7370' class='u'>;;; starting from the PARSE-STATE parameter.
</a>
(<a id='5033' tid='5034' class='u'>defun</a> <a id='5035' tid='5036' class='u'>paredit-kill-word-hack</a> (<a id='5037' tid='5038' class='u'>old-state</a> <a id='5039' tid='5040' class='u'>new-state</a> <a id='5041' tid='5042' class='u'>parse-state</a>)
  (<a id='5043' tid='5044' class='u'>cond</a> ((<a id='5045' tid='5046' class='u'>and</a> (<a id='5047' tid='5048' class='u'>not</a> (<a id='5049' tid='5050' class='u'>eq</a> <a id='5051' tid='5052' class='u'>old-state</a> <a id='5053' tid='5054' class='u'>&#39;</a><a id='5055' tid='5056' class='u'>comment</a>))
              (<a id='5057' tid='5058' class='u'>not</a> (<a id='5059' tid='5060' class='u'>eq</a> <a id='5061' tid='5062' class='u'>new-state</a> <a id='5063' tid='5064' class='u'>&#39;</a><a id='5065' tid='5066' class='u'>comment</a>))
              (<a id='5067' tid='5068' class='u'>not</a> (<a id='5069' tid='5070' class='u'>paredit-in-string-escape-p</a>))
              (<a id='5071' tid='5072' class='u'>eq</a> <a id='5073' tid='5074' class='u'>?\#</a> (<a id='5075' tid='5076' class='u'>char-before</a>))
              (<a id='5077' tid='5078' class='u'>eq</a> <a id='5079' tid='5080' class='u'>?\|</a> (<a id='5081' tid='5082' class='u'>char-after</a>)))
         (<a id='5083' tid='5084' class='u'>forward-char</a> <a id='5085' tid='5086' class='u'>1</a>)
         (<a id='5087' tid='5088' class='u'>paredit-current-parse-state</a>)
<a id='5089' tid='5090' class='u'>;;          (parse-partial-sexp (point) (1+ (point))
</a><a id='5091' tid='5092' class='u'>;;                              nil nil parse-state)
</a>         )
        ((<a id='5093' tid='5094' class='u'>and</a> (<a id='5095' tid='5096' class='u'>not</a> (<a id='5097' tid='5098' class='u'>eq</a> <a id='5099' tid='5100' class='u'>old-state</a> <a id='5101' tid='5102' class='u'>&#39;</a><a id='5103' tid='5104' class='u'>comment</a>))
              (<a id='5105' tid='5106' class='u'>eq</a> <a id='5107' tid='5108' class='u'>new-state</a> <a id='5109' tid='5110' class='u'>&#39;</a><a id='5111' tid='5112' class='u'>comment</a>)
              (<a id='5113' tid='5114' class='u'>eq</a> <a id='5115' tid='5116' class='u'>?\;</a> (<a id='5117' tid='5118' class='u'>char-before</a>)))
         (<a id='5119' tid='5120' class='u'>skip-chars-forward</a> <a id='5121' tid='5122' class='u'>&quot;;&quot;</a>)
         (<a id='5123' tid='5124' class='u'>paredit-current-parse-state</a>)
<a id='5125' tid='5126' class='u'>;;          (parse-partial-sexp (point) (save-excursion
</a><a id='5127' tid='5128' class='u'>;;                                        (skip-chars-forward &quot;;&quot;))
</a><a id='5129' tid='5130' class='u'>;;                              nil nil parse-state)
</a>         )
        (<a id='5131' tid='5132' class='u'>t</a> <a id='5133' tid='5134' class='u'>parse-state</a>)))

(<a id='2751' tid='2752' class='u'>defun</a> <a id='2753' tid='2754' class='u'>paredit-copy-as-kill</a> ()
  <a id='2755' tid='2756' class='u'>&quot;Save in the kill ring the region that `paredit-kill&#39; would kill.&quot;</a>
  (<a id='2757' tid='2758' class='u'>interactive</a>)
  (<a id='2759' tid='2760' class='u'>cond</a> ((<a id='2761' tid='2762' class='u'>paredit-in-string-p</a>)
         (<a id='2763' tid='2764' class='u'>paredit-copy-as-kill-in-string</a>))
        ((<a id='2765' tid='2766' class='u'>paredit-in-comment-p</a>)
         (<a id='2767' tid='2768' class='u'>copy-region-as-kill</a> (<a id='2769' tid='2770' class='u'>point</a>) (<a id='2771' tid='2772' class='u'>point-at-eol</a>)))
        ((<a id='2773' tid='2774' class='u'>save-excursion</a> (<a id='2775' tid='2776' class='u'>paredit-skip-whitespace</a> <a id='2777' tid='2778' class='u'>t</a> (<a id='2779' tid='2780' class='u'>point-at-eol</a>))
                         (<a id='2781' tid='2782' class='u'>or</a> (<a id='2783' tid='2784' class='u'>eolp</a>) (<a id='2785' tid='2786' class='u'>eq</a> (<a id='2787' tid='2788' class='u'>char-after</a>) <a id='2789' tid='2790' class='u'>?\;</a> )))
         <a id='2791' tid='2792' class='u'>;** Be careful about trailing backslashes.
</a>         (<a id='2793' tid='2794' class='u'>save-excursion</a>
           (<a id='2795' tid='2796' class='u'>if</a> (<a id='2797' tid='2798' class='u'>paredit-in-char-p</a>)
               (<a id='2799' tid='2800' class='u'>backward-char</a>))
           (<a id='2801' tid='2802' class='u'>copy-region-as-kill</a> (<a id='2803' tid='2804' class='u'>point</a>) (<a id='2805' tid='2806' class='u'>point-at-eol</a>))))
        (<a id='2807' tid='2808' class='u'>t</a> (<a id='2809' tid='2810' class='u'>paredit-copy-sexps-as-kill</a>))))

(<a id='2811' tid='2812' class='u'>defun</a> <a id='2813' tid='2814' class='u'>paredit-copy-as-kill-in-string</a> ()
  (<a id='2815' tid='2816' class='u'>save-excursion</a>
    (<a id='2817' tid='2818' class='u'>if</a> (<a id='2819' tid='2820' class='u'>paredit-in-string-escape-p</a>)
        (<a id='2821' tid='2822' class='u'>backward-char</a>))
    (<a id='2823' tid='2824' class='u'>copy-region-as-kill</a> (<a id='2825' tid='2826' class='u'>point</a>)
                         (<a id='2827' tid='2828' class='u'>min</a> (<a id='2829' tid='2830' class='u'>point-at-eol</a>)
                              (<a id='2831' tid='2832' class='u'>cdr</a> (<a id='2833' tid='2834' class='u'>paredit-string-start+end-points</a>))))))

(<a id='2835' tid='2836' class='u'>defun</a> <a id='2837' tid='2838' class='u'>paredit-copy-sexps-as-kill</a> ()
  (<a id='2839' tid='2840' class='u'>save-excursion</a>
    (<a id='2841' tid='2842' class='u'>if</a> (<a id='2843' tid='2844' class='u'>paredit-in-char-p</a>)
        (<a id='2845' tid='2846' class='u'>backward-char</a> <a id='2847' tid='2848' class='u'>2</a>))
    (<a id='2849' tid='2850' class='u'>let</a> ((<a id='2851' tid='2852' class='u'>beginning</a> (<a id='2853' tid='2854' class='u'>point</a>))
          (<a id='2855' tid='2856' class='u'>eol</a> (<a id='2857' tid='2858' class='u'>point-at-eol</a>)))
      (<a id='2859' tid='2860' class='u'>let</a> ((<a id='2861' tid='2862' class='u'>end-of-list-p</a> (<a id='2863' tid='2864' class='u'>paredit-forward-sexps-to-kill</a> <a id='2865' tid='2866' class='u'>beginning</a> <a id='2867' tid='2868' class='u'>eol</a>)))
        (<a id='2869' tid='2870' class='u'>if</a> <a id='2871' tid='2872' class='u'>end-of-list-p</a> (<a id='2873' tid='2874' class='u'>progn</a> (<a id='2875' tid='2876' class='u'>up-list</a>) (<a id='2877' tid='2878' class='u'>backward-char</a>)))
        (<a id='2879' tid='2880' class='u'>copy-region-as-kill</a> <a id='2881' tid='2882' class='u'>beginning</a>
                             (<a id='2883' tid='2884' class='u'>cond</a> (<a id='2885' tid='2886' class='u'>kill-whole-line</a>
                                    (<a id='2887' tid='2888' class='u'>or</a> (<a id='2889' tid='2890' class='u'>save-excursion</a>
                                          (<a id='2891' tid='2892' class='u'>paredit-skip-whitespace</a> <a id='2893' tid='2894' class='u'>t</a>)
                                          (<a id='2895' tid='2896' class='u'>and</a> (<a id='2897' tid='2898' class='u'>not</a> (<a id='2899' tid='2900' class='u'>eq</a> (<a id='2901' tid='2902' class='u'>char-after</a>) <a id='2903' tid='2904' class='u'>?\;</a> ))
                                               (<a id='2905' tid='2906' class='u'>point</a>)))
                                        (<a id='2907' tid='2908' class='u'>point-at-eol</a>)))
                                   ((<a id='2909' tid='2910' class='u'>and</a> (<a id='2911' tid='2912' class='u'>not</a> <a id='2913' tid='2914' class='u'>end-of-list-p</a>)
                                         (<a id='2915' tid='2916' class='u'>eq</a> (<a id='2917' tid='2918' class='u'>point-at-eol</a>) <a id='2919' tid='2920' class='u'>eol</a>))
                                    <a id='2921' tid='2922' class='u'>eol</a>)
                                   (<a id='2923' tid='2924' class='u'>t</a>
                                    (<a id='2925' tid='2926' class='u'>point</a>))))))))

<span class='d'>;;;; Safe Region Killing/Copying
</span>
<span class='d'>;;; This is an experiment.  It&#39;s not enough: `paredit-kill-ring-save&#39;
</span><span class='d'>;;; is always safe; it&#39;s `yank&#39; that&#39;s not safe, but even trickier to
</span><span class='d'>;;; implement than `paredit-kill-region&#39;.  Also, the heuristics for
</span><span class='d'>;;; `paredit-kill-region&#39; are slightly too conservative -- they will
</span><span class='d'>;;; sometimes reject killing regions that would be safe to kill.
</span><span class='d'>;;; (Consider, e,g., a region that starts in a comment and ends in the
</span><span class='d'>;;; middle of a symbol at the end of a line: that&#39;s safe to kill, but
</span><span class='d'>;;; `paredit-kill-region&#39; won&#39;t allow it.)  I don&#39;t know whether they
</span><span class='d'>;;; are too liberal: I haven&#39;t constructed a region that is unsafe to
</span><span class='d'>;;; kill but which `paredit-kill-region&#39; will kill, but I haven&#39;t ruled
</span><span class='d'>;;; out the possibility either.
</span>
<span class='d'>(defun paredit-kill-ring-save (beginning end)
  &quot;Save the balanced region, but don&#39;t kill it, like `kill-ring-save&#39;.
If the text of the region is imbalanced, signal an error instead.
With a prefix argument, disregard any imbalance.&quot;
  (interactive &quot;r&quot;)
  (if (not current-prefix-arg)
      (paredit-check-region beginning end))
  (setq this-command &#39;kill-ring-save)
  (kill-ring-save beginning end))</span>

(<a id='4605' tid='4606' class='u'>defun</a> <a id='4607' tid='4608' class='u'>paredit-kill-region</a> <span class='d'>(beginning end &optional yank-handler)</span>
  <span class='d'>&quot;Kill balanced text between point and mark, like `kill-region&#39;.
If that text is imbalanced, signal an error instead.&quot;</span>
  (<a id='4609' tid='4610' class='u'>interactive</a> <a id='4611' tid='4612' class='u'>&quot;r&quot;</a>)
  <span class='d'>(if (and beginning end)
      ;; Check that region begins and ends in a sufficiently similar
      ;; state, so that deleting it will leave the buffer balanced.
      (save-excursion
        (goto-char beginning)
        (let* ((state (paredit-current-parse-state))
               (state* (parse-partial-sexp beginning end nil nil state)))
          (paredit-check-region-state state state*))))</span>
  (<a id='4613' tid='4614' class='u'>setq</a> <a id='4615' tid='4616' class='u'>this-command</a> <a id='4617' tid='4618' class='u'>&#39;</a><a id='4619' tid='4620' class='u'>kill-region</a>)
  <span class='d'>(kill-region beginning end yank-handler)</span>)

<span class='d'>(defun paredit-check-region-state (beginning-state end-state)
  (paredit-check-region-state-depth beginning-state end-state)
  (paredit-check-region-state-string beginning-state end-state)
  (paredit-check-region-state-comment beginning-state end-state)
  (paredit-check-region-state-char-quote beginning-state end-state))</span>

<span class='d'>(defun paredit-check-region-state-depth (beginning-state end-state)
  (let ((beginning-depth (nth 0 beginning-state))
        (end-depth (nth 0 end-state)))
    (if (not (= beginning-depth end-depth))
        (error &quot;Mismatched parenthesis depth: %S at start, %S at end.&quot;
               beginning-depth
               end-depth))))</span>

<span class='d'>(defun paredit-check-region-state-string (beginning-state end-state)
  (let ((beginning-string-p (nth 3 beginning-state))
        (end-string-p (nth 3 end-state)))
    (if (not (eq beginning-string-p end-string-p))
        (error &quot;Mismatched string state: start %sin string, end %sin string.&quot;
               (if beginning-string-p &quot;&quot; &quot;not &quot;)
               (if end-string-p &quot;&quot; &quot;not &quot;)))))</span>

<span class='d'>(defun paredit-check-region-state-comment (beginning-state end-state)
  (let ((beginning-comment-state (nth 4 beginning-state))
        (end-comment-state (nth 4 end-state)))
    (if (not (or (eq beginning-comment-state end-comment-state)
                 (and (eq beginning-comment-state nil)
                      (eq end-comment-state t)
                      (eolp))))
        (error &quot;Mismatched comment state: %s&quot;
               (cond ((and (integerp beginning-comment-state)
                           (integerp end-comment-state))
                      (format &quot;depth %S at start, depth %S at end.&quot;
                              beginning-comment-state
                              end-comment-state))
                     ((integerp beginning-comment-state)
                      &quot;start in nested comment, end otherwise.&quot;)
                     ((integerp end-comment-state)
                      &quot;end in nested comment, start otherwise.&quot;)
                     (beginning-comment-state
                      &quot;start in comment, end not in comment.&quot;)
                     (end-comment-state
                      &quot;end in comment, start not in comment.&quot;)
                     (t
                      (format &quot;start %S, end %S.&quot;
                              beginning-comment-state
                              end-comment-state)))))))</span>

<span class='d'>(defun paredit-check-region-state-char-quote (beginning-state end-state)
  (let ((beginning-char-quote (nth 5 beginning-state))
        (end-char-quote (nth 5 end-state)))
    (if (not (eq beginning-char-quote end-char-quote))
        (let ((phrase &quot;character quotation&quot;))
          (error &quot;Mismatched %s: start %sin %s, end %sin %s.&quot;
                 phrase
                 (if beginning-char-quote &quot;&quot; &quot;not &quot;)
                 phrase
                 (if end-char-quote &quot;&quot; &quot;not &quot;)
                 phrase)))))</span>

<span class='d'>;;;; Cursor and Screen Movement
</span>
(<a id='7371' tid='7372' class='u'>eval-and-compile</a>
  (<a id='7409' tid='7410' class='u'>defmacro</a> <a id='7411' tid='7412' class='u'>defun-saving-mark</a> (<a id='7413' tid='7414' class='u'>name</a> <a id='7415' tid='7416' class='u'>bvl</a> <a id='7417' tid='7418' class='u'>doc</a> <a id='7419' tid='7420' class='u'>&rest</a> <a id='7421' tid='7422' class='u'>body</a>)
    <a id='7423' tid='7424' class='u'>`</a>(<a id='7373' tid='7374' class='u'>defun</a> <a id='7375' tid='7376' class='u'>,</a><a id='7377' tid='7378' class='u'>name</a> <a id='7379' tid='7380' class='u'>,</a><a id='7381' tid='7382' class='u'>bvl</a>
       <a id='7383' tid='7384' class='u'>,</a><a id='7385' tid='7386' class='u'>doc</a>
       <a id='7387' tid='7388' class='u'>,</a>(<a id='7389' tid='7390' class='u'>xcond</a> ((<a id='7391' tid='7392' class='u'>paredit-xemacs-p</a>)
                <a id='7393' tid='7394' class='u'>&#39;</a>(<a id='7395' tid='7396' class='u'>interactive</a> <a id='7397' tid='7398' class='u'>&quot;_&quot;</a>))
               ((<a id='7399' tid='7400' class='u'>paredit-gnu-emacs-p</a>)
                <a id='7401' tid='7402' class='u'>&#39;</a>(<a id='7403' tid='7404' class='u'>interactive</a>)))
       <a id='7405' tid='7406' class='u'>,</a><a id='7407' tid='7408' class='u'>@body</a>)))

(<a id='7425' tid='7426' class='u'>defun-saving-mark</a> <a id='7427' tid='7428' class='u'>paredit-forward</a> ()
  <a id='7429' tid='7430' class='u'>&quot;Move forward an S-expression, or up an S-expression forward.
If there are no more S-expressions in this one before the closing
  delimiter, move past that closing delimiter; otherwise, move forward
  past the S-expression following the point.&quot;</a>
  (<a id='7431' tid='7432' class='u'>paredit-handle-sexp-errors</a>
      (<a id='7433' tid='7434' class='u'>forward-sexp</a>)
    <span class='d'>;++ Is it necessary to use UP-LIST and not just FORWARD-CHAR?
</span>    (<a id='7435' tid='7436' class='u'>if</a> (<a id='7437' tid='7438' class='u'>paredit-in-string-p</a>) (<a id='7439' tid='7440' class='u'>forward-char</a>) (<a id='7441' tid='7442' class='u'>up-list</a>))))

(<a id='7443' tid='7444' class='u'>defun-saving-mark</a> <a id='7445' tid='7446' class='u'>paredit-backward</a> ()
  <a id='7447' tid='7448' class='u'>&quot;Move backward an S-expression, or up an S-expression backward.
If there are no more S-expressions in this one before the opening
  delimiter, move past that opening delimiter backward; otherwise, move
  move backward past the S-expression preceding the point.&quot;</a>
  (<a id='7449' tid='7450' class='u'>paredit-handle-sexp-errors</a>
      (<a id='7451' tid='7452' class='u'>backward-sexp</a>)
    (<a id='7453' tid='7454' class='u'>if</a> (<a id='7455' tid='7456' class='u'>paredit-in-string-p</a>) (<a id='7457' tid='7458' class='u'>backward-char</a>) (<a id='7459' tid='7460' class='u'>backward-up-list</a>))))

<a id='7461' tid='7462' class='u'>;;; Why is this not in lisp.el?
</a>
(<a id='1741' tid='1742' class='u'>defun</a> <a id='1743' tid='1744' class='u'>backward-down-list</a> (<a id='1745' tid='1746' class='u'>&optional</a> <a id='1747' tid='1748' class='u'>arg</a>)
  <a id='1749' tid='1750' class='u'>&quot;Move backward and descend into one level of parentheses.
With ARG, do this that many times.
A negative argument means move forward but still descend a level.&quot;</a>
  (<a id='1751' tid='1752' class='u'>interactive</a> <a id='1753' tid='1754' class='u'>&quot;p&quot;</a>)
  (<a id='1755' tid='1756' class='u'>down-list</a> (<a id='1757' tid='1758' class='u'>-</a> (<a id='1759' tid='1760' class='u'>or</a> <a id='1761' tid='1762' class='u'>arg</a> <a id='1763' tid='1764' class='u'>1</a>))))

<span class='d'>;;; Thanks to Marco Baringer for suggesting & writing this function.
</span>
<span class='d'>(defun paredit-recentre-on-sexp (&optional n)
  &quot;Recentre the screen on the S-expression following the point.
With a prefix argument N, encompass all N S-expressions forward.&quot;
  (interactive &quot;P&quot;)
  (save-excursion
    (forward-sexp n)
    (let ((end-point (point)))
      (backward-sexp n)
      (let* ((start-point (point))
             (start-line (count-lines (point-min) (point)))
             (lines-on-sexps (count-lines start-point end-point)))
        (goto-line (+ start-line (/ lines-on-sexps 2)))
        (recenter)))))</span>

(<a id='3197' tid='3198' class='u'>defun</a> <a id='3199' tid='3200' class='u'>paredit-focus-on-defun</a> ()
  <a id='3201' tid='3202' class='u'>&quot;Moves display to the top of the definition at point.&quot;</a>
  (<a id='3203' tid='3204' class='u'>interactive</a>)
  (<a id='3205' tid='3206' class='u'>beginning-of-defun</a>)
  (<a id='3207' tid='3208' class='u'>recenter</a> <a id='3209' tid='3210' class='u'>0</a>))

<span class='d'>;;;; Generalized Upward/Downward Motion
</span>
(<a id='6487' tid='6488' class='u'>defun</a> <a id='6489' tid='6490' class='u'>paredit-up/down</a> (<a id='6491' tid='6492' class='u'>n</a> <a id='6493' tid='6494' class='u'>vertical-direction</a>)
  (<a id='6495' tid='6496' class='u'>let</a> ((<a id='6497' tid='6498' class='u'>horizontal-direction</a> (<a id='6499' tid='6500' class='u'>if</a> (<a id='6501' tid='6502' class='u'>&lt;</a> <a id='6503' tid='6504' class='u'>0</a> <a id='6505' tid='6506' class='u'>n</a>) <a id='6507' tid='6508' class='u'>+1</a> <a id='6509' tid='6510' class='u'>-1</a>)))
    (<a id='6511' tid='6512' class='u'>while</a> (<a id='6513' tid='6514' class='u'>/=</a> <a id='6515' tid='6516' class='u'>n</a> <a id='6517' tid='6518' class='u'>0</a>)
      (<a id='6519' tid='6520' class='u'>goto-char</a>
       (<a id='6521' tid='6522' class='u'>paredit-next-up/down-point</a> <a id='6523' tid='6524' class='u'>horizontal-direction</a> <a id='6525' tid='6526' class='u'>vertical-direction</a>))
      (<a id='6527' tid='6528' class='u'>setq</a> <a id='6529' tid='6530' class='u'>n</a> (<a id='6531' tid='6532' class='u'>-</a> <a id='6533' tid='6534' class='u'>n</a> <a id='6535' tid='6536' class='u'>horizontal-direction</a>)))))

(<a id='5467' tid='5468' class='u'>defun</a> <a id='5469' tid='5470' class='u'>paredit-next-up/down-point</a> (<a id='5471' tid='5472' class='u'>horizontal-direction</a> <a id='5473' tid='5474' class='u'>vertical-direction</a>)
  (<a id='5475' tid='5476' class='u'>let</a> ((<a id='5477' tid='5478' class='u'>state</a> (<a id='5479' tid='5480' class='u'>paredit-current-parse-state</a>))
        (<a id='5481' tid='5482' class='u'>scan-lists</a>
         (<a id='5483' tid='5484' class='u'>lambda</a> ()
           (<a id='5485' tid='5486' class='u'>scan-lists</a> (<a id='5487' tid='5488' class='u'>point</a>) <a id='5489' tid='5490' class='u'>horizontal-direction</a> <a id='5491' tid='5492' class='u'>vertical-direction</a>))))
    (<a id='5493' tid='5494' class='u'>cond</a> ((<a id='5495' tid='5496' class='u'>paredit-in-string-p</a> <a id='5497' tid='5498' class='u'>state</a>)
           (<a id='5499' tid='5500' class='u'>let</a> ((<a id='5501' tid='5502' class='u'>start+end</a> (<a id='5503' tid='5504' class='u'>paredit-string-start+end-points</a> <a id='5505' tid='5506' class='u'>state</a>)))
             (<a id='5507' tid='5508' class='u'>if</a> (<a id='5509' tid='5510' class='u'>&lt;</a> <a id='5511' tid='5512' class='u'>0</a> <a id='5513' tid='5514' class='u'>vertical-direction</a>)
                 (<a id='5515' tid='5516' class='u'>if</a> (<a id='5517' tid='5518' class='u'>&lt;</a> <a id='5519' tid='5520' class='u'>0</a> <a id='5521' tid='5522' class='u'>horizontal-direction</a>)
                     (<a id='5523' tid='5524' class='u'>+</a> <a id='5525' tid='5526' class='u'>1</a> (<a id='5527' tid='5528' class='u'>cdr</a> <a id='5529' tid='5530' class='u'>start+end</a>))
                     (<a id='5531' tid='5532' class='u'>car</a> <a id='5533' tid='5534' class='u'>start+end</a>))
                 <a id='5535' tid='5536' class='u'>;; We could let the user try to descend into lists
</a>                 <a id='5537' tid='5538' class='u'>;; within the string, but that would be asymmetric
</a>                 <a id='5539' tid='5540' class='u'>;; with the up case, which rises out of the whole
</a>                 <a id='5541' tid='5542' class='u'>;; string and not just out of a list within the
</a>                 <a id='5543' tid='5544' class='u'>;; string, so this case will just be an error.
</a>                 (<a id='5545' tid='5546' class='u'>error</a> <a id='5547' tid='5548' class='u'>&quot;Can&#39;t descend further into string.&quot;</a>))))
          ((<a id='5549' tid='5550' class='u'>&lt;</a> <a id='5551' tid='5552' class='u'>0</a> <a id='5553' tid='5554' class='u'>vertical-direction</a>)
           <a id='5555' tid='5556' class='u'>;; When moving up, just try to rise up out of the list.
</a>           (<a id='5557' tid='5558' class='u'>or</a> (<a id='5559' tid='5560' class='u'>funcall</a> <a id='5561' tid='5562' class='u'>scan-lists</a>)
               (<a id='5563' tid='5564' class='u'>buffer-end</a> <a id='5565' tid='5566' class='u'>horizontal-direction</a>)))
          ((<a id='5567' tid='5568' class='u'>&lt;</a> <a id='5569' tid='5570' class='u'>vertical-direction</a> <a id='5571' tid='5572' class='u'>0</a>)
           <a id='5573' tid='5574' class='u'>;; When moving down, look for a string closer than a list,
</a>           <a id='5575' tid='5576' class='u'>;; and use that if we find it.
</a>           (<a id='5577' tid='5578' class='u'>let*</a> ((<a id='5579' tid='5580' class='u'>list-start</a>
                   (<a id='5581' tid='5582' class='u'>paredit-handle-sexp-errors</a> (<a id='5583' tid='5584' class='u'>funcall</a> <a id='5585' tid='5586' class='u'>scan-lists</a>) <a id='5587' tid='5588' class='u'>nil</a>))
                  (<a id='5589' tid='5590' class='u'>string-start</a>
                   (<a id='5591' tid='5592' class='u'>paredit-find-next-string-start</a> <a id='5593' tid='5594' class='u'>horizontal-direction</a>
                                                   <a id='5595' tid='5596' class='u'>list-start</a>)))
             (<a id='5597' tid='5598' class='u'>if</a> (<a id='5599' tid='5600' class='u'>and</a> <a id='5601' tid='5602' class='u'>string-start</a> <a id='5603' tid='5604' class='u'>list-start</a>)
                 (<a id='5605' tid='5606' class='u'>if</a> (<a id='5607' tid='5608' class='u'>&lt;</a> <a id='5609' tid='5610' class='u'>0</a> <a id='5611' tid='5612' class='u'>horizontal-direction</a>)
                     (<a id='5613' tid='5614' class='u'>min</a> <a id='5615' tid='5616' class='u'>string-start</a> <a id='5617' tid='5618' class='u'>list-start</a>)
                     (<a id='5619' tid='5620' class='u'>max</a> <a id='5621' tid='5622' class='u'>string-start</a> <a id='5623' tid='5624' class='u'>list-start</a>))
                 (<a id='5625' tid='5626' class='u'>or</a> <a id='5627' tid='5628' class='u'>string-start</a>
                     <a id='5629' tid='5630' class='u'>;; Scan again: this is a kludgey way to report the
</a>                     <a id='5631' tid='5632' class='u'>;; error if there really was one.
</a>                     (<a id='5633' tid='5634' class='u'>funcall</a> <a id='5635' tid='5636' class='u'>scan-lists</a>)
                     (<a id='5637' tid='5638' class='u'>buffer-end</a> <a id='5639' tid='5640' class='u'>horizontal-direction</a>)))))
          (<a id='5641' tid='5642' class='u'>t</a>
           (<a id='5643' tid='5644' class='u'>error</a> <a id='5645' tid='5646' class='u'>&quot;Vertical direction must be nonzero in `%s&#39;.&quot;</a>
                  <a id='5647' tid='5648' class='u'>&#39;</a><a id='5649' tid='5650' class='u'>paredit-up/down</a>)))))

(<a id='3189' tid='3190' class='u'>defun</a> <a id='3191' tid='3192' class='u'>paredit-find-next-string-start</a> (<a id='3193' tid='3194' class='u'>horizontal-direction</a> <a id='3195' tid='3196' class='u'>limit</a>)
  (<a id='1277' tid='1278' class='m'>let</a> ((<a id='1279' tid='1280' class='m'>next-char</a> (<a id='1281' tid='1282' class='m'>if</a> (<a id='1283' tid='1284' class='m'>&lt;</a> <a id='1285' tid='1286' class='m'>0</a> <a id='1287' tid='1288' class='m'>horizontal-direction</a>) <a id='1289' tid='1290' class='m'>&#39;</a><a id='1291' tid='1292' class='m'>char-after</a> <a id='1293' tid='1294' class='m'>&#39;</a><a id='1295' tid='1296' class='m'>char-before</a>))
        <span class='d'>(pastp (if (&lt; 0 horizontal-direction) &#39;&lt; &#39;&gt;))</span>)
    (<a id='1297' tid='1298' class='m'>paredit-handle-sexp-errors</a>
        (<a id='1299' tid='1300' class='m'>save-excursion</a>
          (<a id='1301' tid='1302' class='m'>catch</a> <a id='1303' tid='1304' class='m'>&#39;</a><a id='1305' tid='1306' class='m'>exit</a>
            (<a id='1307' tid='1308' class='m'>while</a> <a id='1309' tid='1310' class='m'>t</a>
              (<a id='1311' tid='1312' class='m'>if</a> (<a id='1313' tid='1314' class='m'>and</a> <a id='1315' tid='1316' class='m'>limit</a> (<a id='1317' tid='1318' class='m'>funcall</a> <a id='1319' tid='1320' class='m'>pastp</a> (<a id='1321' tid='1322' class='m'>point</a>) <a id='1323' tid='1324' class='m'>limit</a>))
                  (<a id='1325' tid='1326' class='m'>throw</a> <a id='1327' tid='1328' class='m'>&#39;</a><a id='1329' tid='1330' class='m'>exit</a> <a id='1331' tid='1332' class='m'>nil</a>))
              (<a id='1333' tid='1334' class='m'>forward-sexp</a> <a id='1335' tid='1336' class='m'>horizontal-direction</a>)
              (<a id='1337' tid='1338' class='m'>save-excursion</a>
                (<a id='1339' tid='1340' class='m'>backward-sexp</a> <a id='1341' tid='1342' class='m'>horizontal-direction</a>)
                (<a id='1343' tid='1344' class='m'>if</a> (<a id='1345' tid='1346' class='m'>eq</a> <a id='1347' tid='1348' class='m'>?\&quot;</a> (<a id='1349' tid='1350' class='m'>char-syntax</a> (<a id='1351' tid='1352' class='m'>funcall</a> <a id='1353' tid='1354' class='m'>next-char</a>)))
                    (<a id='1355' tid='1356' class='m'>throw</a> <a id='1357' tid='1358' class='m'>&#39;</a><a id='1359' tid='1360' class='m'>exit</a> (<a id='1361' tid='1362' class='m'>+</a> (<a id='1363' tid='1364' class='m'>point</a>) <a id='1365' tid='1366' class='m'>horizontal-direction</a>)))))))
      <a id='1367' tid='1368' class='m'>nil</a>)))

(<a id='3349' tid='3350' class='u'>defun</a> <a id='3351' tid='3352' class='u'>paredit-forward-down</a> (<a id='3353' tid='3354' class='u'>&optional</a> <a id='3355' tid='3356' class='u'>argument</a>)
  <a id='3357' tid='3358' class='u'>&quot;Move forward down into a list.
With a positive argument, move forward down that many levels.
With a negative argument, move backward down that many levels.&quot;</a>
  (<a id='3359' tid='3360' class='u'>interactive</a> <a id='3361' tid='3362' class='u'>&quot;p&quot;</a>)
  (<a id='3363' tid='3364' class='u'>paredit-up/down</a> (<a id='3365' tid='3366' class='u'>or</a> <a id='3367' tid='3368' class='u'>argument</a> <a id='3369' tid='3370' class='u'>+1</a>) <a id='3371' tid='3372' class='u'>-1</a>))

(<a id='2541' tid='2542' class='u'>defun</a> <a id='2543' tid='2544' class='u'>paredit-backward-up</a> (<a id='2545' tid='2546' class='u'>&optional</a> <a id='2547' tid='2548' class='u'>argument</a>)
  <a id='2549' tid='2550' class='u'>&quot;Move backward up out of the enclosing list.
With a positive argument, move backward up that many levels.
With a negative argument, move forward up that many levels.
If in a string initially, that counts as one level.&quot;</a>
  (<a id='2551' tid='2552' class='u'>interactive</a> <a id='2553' tid='2554' class='u'>&quot;p&quot;</a>)
  (<a id='2555' tid='2556' class='u'>paredit-up/down</a> (<a id='2557' tid='2558' class='u'>-</a> <a id='2559' tid='2560' class='u'>0</a> (<a id='2561' tid='2562' class='u'>or</a> <a id='2563' tid='2564' class='u'>argument</a> <a id='2565' tid='2566' class='u'>+1</a>)) <a id='2567' tid='2568' class='u'>+1</a>))

(<a id='3885' tid='3886' class='u'>defun</a> <a id='3887' tid='3888' class='u'>paredit-forward-up</a> (<a id='3889' tid='3890' class='u'>&optional</a> <a id='3891' tid='3892' class='u'>argument</a>)
  <a id='3893' tid='3894' class='u'>&quot;Move forward up out of the enclosing list.
With a positive argument, move forward up that many levels.
With a negative argument, move backward up that many levels.
If in a string initially, that counts as one level.&quot;</a>
  (<a id='3895' tid='3896' class='u'>interactive</a> <a id='3897' tid='3898' class='u'>&quot;p&quot;</a>)
  (<a id='3899' tid='3900' class='u'>paredit-up/down</a> (<a id='3901' tid='3902' class='u'>or</a> <a id='3903' tid='3904' class='u'>argument</a> <a id='3905' tid='3906' class='u'>+1</a>) <a id='3907' tid='3908' class='u'>+1</a>))

(<a id='2217' tid='2218' class='u'>defun</a> <a id='2219' tid='2220' class='u'>paredit-backward-down</a> (<a id='2221' tid='2222' class='u'>&optional</a> <a id='2223' tid='2224' class='u'>argument</a>)
  <a id='2225' tid='2226' class='u'>&quot;Move backward down into a list.
With a positive argument, move backward down that many levels.
With a negative argument, move forward down that many levels.&quot;</a>
  (<a id='2227' tid='2228' class='u'>interactive</a> <a id='2229' tid='2230' class='u'>&quot;p&quot;</a>)
  (<a id='2231' tid='2232' class='u'>paredit-up/down</a> (<a id='2233' tid='2234' class='u'>-</a> <a id='2235' tid='2236' class='u'>0</a> (<a id='2237' tid='2238' class='u'>or</a> <a id='2239' tid='2240' class='u'>argument</a> <a id='2241' tid='2242' class='u'>+1</a>)) <a id='2243' tid='2244' class='u'>-1</a>))

<span class='d'>;;;; Depth-Changing Commands:  Wrapping, Splicing, & Raising
</span>
(<a id='6547' tid='6548' class='u'>defun</a> <a id='6549' tid='6550' class='u'>paredit-wrap-sexp</a> (<a id='6551' tid='6552' class='u'>&optional</a> <a id='6553' tid='6554' class='u'>argument</a> <a id='6555' tid='6556' class='u'>open</a> <a id='6557' tid='6558' class='u'>close</a>)
  <a id='6559' tid='6560' class='u'>&quot;Wrap the following S-expression.
If a `C-u&#39; prefix argument is given, wrap all S-expressions following
  the point until the end of the buffer or of the enclosing list.
If a numeric prefix argument N is given, wrap N S-expressions.
Automatically indent the newly wrapped S-expression.
As a special case, if the point is at the end of a list, simply insert
  a parenthesis pair, rather than inserting a lone opening delimiter
  and then signalling an error, in the interest of preserving
  structure.
By default OPEN and CLOSE are round delimiters.&quot;</a>
  (<a id='6561' tid='6562' class='u'>interactive</a> <a id='6563' tid='6564' class='u'>&quot;P&quot;</a>)
  (<a id='6565' tid='6566' class='u'>paredit-lose-if-not-in-sexp</a> <a id='6567' tid='6568' class='u'>&#39;</a><a id='6569' tid='6570' class='u'>paredit-wrap-sexp</a>)
  (<a id='6571' tid='6572' class='u'>let</a> ((<a id='6573' tid='6574' class='u'>open</a> (<a id='6575' tid='6576' class='u'>or</a> <a id='6577' tid='6578' class='u'>open</a> <a id='6579' tid='6580' class='u'>?\(</a> ))
        (<a id='6581' tid='6582' class='u'>close</a> (<a id='6583' tid='6584' class='u'>or</a> <a id='6585' tid='6586' class='u'>close</a> <a id='6587' tid='6588' class='u'>?\)</a> )))
    (<a id='6589' tid='6590' class='u'>paredit-handle-sexp-errors</a>
        ((<a id='6591' tid='6592' class='u'>lambda</a> (<a id='6593' tid='6594' class='u'>n</a>) (<a id='6595' tid='6596' class='u'>paredit-insert-pair</a> <a id='6597' tid='6598' class='u'>n</a> <a id='6599' tid='6600' class='u'>open</a> <a id='6601' tid='6602' class='u'>close</a> <a id='6603' tid='6604' class='u'>&#39;</a><a id='6605' tid='6606' class='u'>goto-char</a>))
         (<a id='6607' tid='6608' class='u'>cond</a> ((<a id='6609' tid='6610' class='u'>integerp</a> <a id='6611' tid='6612' class='u'>argument</a>) <a id='6613' tid='6614' class='u'>argument</a>)
               ((<a id='6615' tid='6616' class='u'>consp</a> <a id='6617' tid='6618' class='u'>argument</a>) (<a id='6619' tid='6620' class='u'>paredit-count-sexps-forward</a>))
               ((<a id='6621' tid='6622' class='u'>paredit-region-active-p</a>) <a id='6623' tid='6624' class='u'>nil</a>)
               (<a id='6625' tid='6626' class='u'>t</a> <a id='6627' tid='6628' class='u'>1</a>)))
      (<a id='6629' tid='6630' class='u'>insert</a> <a id='6631' tid='6632' class='u'>close</a>)
      (<a id='6633' tid='6634' class='u'>backward-char</a>)))
  (<a id='6635' tid='6636' class='u'>save-excursion</a> (<a id='6637' tid='6638' class='u'>backward-up-list</a>) (<a id='6639' tid='6640' class='u'>indent-sexp</a>)))

(<a id='2927' tid='2928' class='u'>defun</a> <a id='2929' tid='2930' class='u'>paredit-count-sexps-forward</a> ()
  (<a id='1369' tid='1370' class='m'>save-excursion</a>
    (<span class='d'>let</span> <span class='d'>((n 0))</span>
      (<span class='d'>paredit-ignore-sexp-errors</span>
        (<span class='d'>while</span> <span class='d'>(not (eobp))</span>
          <span class='d'>(forward-sexp)</span>
          (<a id='1371' tid='1372' class='m'>setq</a> <a id='1373' tid='1374' class='m'>n</a> (<a id='1375' tid='1376' class='m'>+</a> <a id='1377' tid='1378' class='m'>n</a> <a id='1379' tid='1380' class='m'>1</a>))))
      <span class='d'>n</span>)))

(<a id='6641' tid='6642' class='u'>defun</a> <a id='6643' tid='6644' class='u'>paredit-yank-pop</a> (<a id='6645' tid='6646' class='u'>&optional</a> <a id='6647' tid='6648' class='u'>argument</a>)
  <a id='6649' tid='6650' class='u'>&quot;Replace just-yanked text with the next item in the kill ring.
If this command follows a `yank&#39;, just run `yank-pop&#39;.
If this command follows a `paredit-wrap-sexp&#39;, or any other paredit
  wrapping command (see `paredit-wrap-commands&#39;), run `yank&#39; and
  reindent the enclosing S-expression.
If this command is repeated, run `yank-pop&#39; and reindent the enclosing
  S-expression.

The argument is passed on to `yank&#39; or `yank-pop&#39;; see their
  documentation for details.&quot;</a>
  (<a id='6651' tid='6652' class='u'>interactive</a> <a id='6653' tid='6654' class='u'>&quot;*p&quot;</a>)
  (<a id='6655' tid='6656' class='u'>cond</a> ((<a id='6657' tid='6658' class='u'>eq</a> <a id='6659' tid='6660' class='u'>last-command</a> <a id='6661' tid='6662' class='u'>&#39;</a><a id='6663' tid='6664' class='u'>yank</a>)
         (<a id='6665' tid='6666' class='u'>yank-pop</a> <a id='6667' tid='6668' class='u'>argument</a>))
        ((<a id='6669' tid='6670' class='u'>memq</a> <a id='6671' tid='6672' class='u'>last-command</a> <a id='6673' tid='6674' class='u'>paredit-wrap-commands</a>)
         (<a id='6675' tid='6676' class='u'>yank</a> <a id='6677' tid='6678' class='u'>argument</a>)
         <a id='6679' tid='6680' class='u'>;; `yank&#39; futzes with `this-command&#39;.
</a>         (<a id='6681' tid='6682' class='u'>setq</a> <a id='6683' tid='6684' class='u'>this-command</a> <a id='6685' tid='6686' class='u'>&#39;</a><a id='6687' tid='6688' class='u'>paredit-yank-pop</a>)
         (<a id='6689' tid='6690' class='u'>save-excursion</a> (<a id='6691' tid='6692' class='u'>backward-up-list</a>) (<a id='6693' tid='6694' class='u'>indent-sexp</a>)))
        ((<a id='6695' tid='6696' class='u'>eq</a> <a id='6697' tid='6698' class='u'>last-command</a> <a id='6699' tid='6700' class='u'>&#39;</a><a id='6701' tid='6702' class='u'>paredit-yank-pop</a>)
         <a id='6703' tid='6704' class='u'>;; Pretend we just did a `yank&#39;, so that we can use
</a>         <a id='6705' tid='6706' class='u'>;; `yank-pop&#39; without duplicating its definition.
</a>         (<a id='6707' tid='6708' class='u'>setq</a> <a id='6709' tid='6710' class='u'>last-command</a> <a id='6711' tid='6712' class='u'>&#39;</a><a id='6713' tid='6714' class='u'>yank</a>)
         (<a id='6715' tid='6716' class='u'>yank-pop</a> <a id='6717' tid='6718' class='u'>argument</a>)
         <a id='6719' tid='6720' class='u'>;; Return to our original state.
</a>         (<a id='6721' tid='6722' class='u'>setq</a> <a id='6723' tid='6724' class='u'>last-command</a> <a id='6725' tid='6726' class='u'>&#39;</a><a id='6727' tid='6728' class='u'>paredit-yank-pop</a>)
         (<a id='6729' tid='6730' class='u'>setq</a> <a id='6731' tid='6732' class='u'>this-command</a> <a id='6733' tid='6734' class='u'>&#39;</a><a id='6735' tid='6736' class='u'>paredit-yank-pop</a>)
         (<a id='6737' tid='6738' class='u'>save-excursion</a> (<a id='6739' tid='6740' class='u'>backward-up-list</a>) (<a id='6741' tid='6742' class='u'>indent-sexp</a>)))
        (<a id='6743' tid='6744' class='u'>t</a> (<a id='6745' tid='6746' class='u'>error</a> <a id='6747' tid='6748' class='u'>&quot;Last command was not a yank or a wrap: %s&quot;</a> <a id='6749' tid='6750' class='u'>last-command</a>))))

<span class='d'>;;; Thanks to Marco Baringer for the suggestion of a prefix argument
</span><span class='d'>;;; for PAREDIT-SPLICE-SEXP.  (I, Taylor R. Campbell, however, still
</span><span class='d'>;;; implemented it, in case any of you lawyer-folk get confused by the
</span><span class='d'>;;; remark in the top of the file about explicitly noting code written
</span><span class='d'>;;; by other people.)
</span>
(<a id='6149' tid='6150' class='u'>defun</a> <a id='6151' tid='6152' class='u'>paredit-splice-sexp</a> (<a id='6153' tid='6154' class='u'>&optional</a> <a id='6155' tid='6156' class='u'>argument</a>)
  <a id='6157' tid='6158' class='u'>&quot;Splice the list that the point is on by removing its delimiters.
With a prefix argument as in `C-u&#39;, kill all S-expressions backward in
  the current list before splicing all S-expressions forward into the
  enclosing list.
With two prefix arguments as in `C-u C-u&#39;, kill all S-expressions
  forward in the current list before splicing all S-expressions
  backward into the enclosing list.
With a numerical prefix argument N, kill N S-expressions backward in
  the current list before splicing the remaining S-expressions into the
  enclosing list.  If N is negative, kill forward.
Inside a string, unescape all backslashes, or signal an error if doing
  so would invalidate the buffer&#39;s structure.&quot;</a>
  (<a id='6159' tid='6160' class='u'>interactive</a> <a id='6161' tid='6162' class='u'>&quot;P&quot;</a>)
  (<a id='1381' tid='1382' class='m'>if</a> (<a id='1383' tid='1384' class='m'>paredit-in-string-p</a>)
      (<a id='1385' tid='1386' class='m'>paredit-splice-string</a> <a id='1387' tid='1388' class='m'>argument</a>)
      (<a id='1389' tid='1390' class='m'>save-excursion</a>
        (<a id='1391' tid='1392' class='m'>paredit-kill-surrounding-sexps-for-splice</a> <a id='1393' tid='1394' class='m'>argument</a>)
        (<a id='1395' tid='1396' class='m'>let</a> ((<a id='1397' tid='1398' class='m'>end</a> (<a id='1399' tid='1400' class='m'>point</a>)))
          (<a id='1401' tid='1402' class='m'>backward-up-list</a>)            <a id='1403' tid='1404' class='m'>; Go up to the beginning...
</a>          (<a id='1405' tid='1406' class='m'>save-excursion</a>
            (<a id='1407' tid='1408' class='m'>forward-char</a> <a id='1409' tid='1410' class='m'>1</a>)            <a id='1411' tid='1412' class='m'>; (Skip over leading whitespace
</a>            (<a id='1413' tid='1414' class='m'>paredit-skip-whitespace</a> <a id='1415' tid='1416' class='m'>t</a> <a id='1417' tid='1418' class='m'>end</a>)
            (<a id='1419' tid='1420' class='m'>setq</a> <a id='1421' tid='1422' class='m'>end</a> (<a id='1423' tid='1424' class='m'>point</a>)))         <a id='1425' tid='1426' class='m'>;   for the `delete-region&#39;.)
</a>          (<span class='d'>let</span> <span class='d'>((indent-start nil) (indent-end nil))</span>
            (<a id='1427' tid='1428' class='m'>save-excursion</a>
              (<a id='1429' tid='1430' class='m'>setq</a> <a id='1431' tid='1432' class='m'>indent-start</a> (<a id='1433' tid='1434' class='m'>point</a>))
              (<a id='1435' tid='1436' class='m'>forward-sexp</a>)            <a id='1437' tid='1438' class='m'>; Go forward an expression, to
</a>              (<a id='1439' tid='1440' class='m'>backward-delete-char</a> <a id='1441' tid='1442' class='m'>1</a>)  <a id='1443' tid='1444' class='m'>;   delete the end delimiter.
</a>              (<a id='1445' tid='1446' class='m'>setq</a> <a id='1447' tid='1448' class='m'>indent-end</a> (<a id='1449' tid='1450' class='m'>point</a>)))
            <span class='d'>(delete-region (point) end)</span> <span class='d'>; ...to delete the open char.
</span>            <span class='d'>;; Reindent only the region we preserved.
</span>            <span class='d'>(indent-region indent-start indent-end)</span>)))))

(<a id='4859' tid='4860' class='u'>defun</a> <a id='4861' tid='4862' class='u'>paredit-kill-surrounding-sexps-for-splice</a> (<a id='4863' tid='4864' class='u'>argument</a>)
  (<a id='4865' tid='4866' class='u'>cond</a> ((<a id='4867' tid='4868' class='u'>or</a> (<a id='4869' tid='4870' class='u'>paredit-in-string-p</a>)
             (<a id='4871' tid='4872' class='u'>paredit-in-comment-p</a>))
         (<a id='4873' tid='4874' class='u'>error</a> <a id='4875' tid='4876' class='u'>&quot;Invalid context for splicing S-expressions.&quot;</a>))
        ((<a id='4877' tid='4878' class='u'>or</a> (<a id='4879' tid='4880' class='u'>not</a> <a id='4881' tid='4882' class='u'>argument</a>) (<a id='4883' tid='4884' class='u'>eq</a> <a id='4885' tid='4886' class='u'>argument</a> <a id='4887' tid='4888' class='u'>0</a>)) <a id='4889' tid='4890' class='u'>nil</a>)
        ((<a id='4891' tid='4892' class='u'>or</a> (<a id='4893' tid='4894' class='u'>numberp</a> <a id='4895' tid='4896' class='u'>argument</a>) (<a id='4897' tid='4898' class='u'>eq</a> <a id='4899' tid='4900' class='u'>argument</a> <a id='4901' tid='4902' class='u'>&#39;</a><a id='4903' tid='4904' class='u'>-</a>))
         <a id='4905' tid='4906' class='u'>;; Kill S-expressions before/after the point by saving the
</a>         <a id='4907' tid='4908' class='u'>;; point, moving across them, and killing the region.
</a>         (<a id='4909' tid='4910' class='u'>let*</a> ((<a id='4911' tid='4912' class='u'>argument</a> (<a id='4913' tid='4914' class='u'>if</a> (<a id='4915' tid='4916' class='u'>eq</a> <a id='4917' tid='4918' class='u'>argument</a> <a id='4919' tid='4920' class='u'>&#39;</a><a id='4921' tid='4922' class='u'>-</a>) <a id='4923' tid='4924' class='u'>-1</a> <a id='4925' tid='4926' class='u'>argument</a>))
                (<a id='4927' tid='4928' class='u'>saved</a> (<a id='4929' tid='4930' class='u'>paredit-point-at-sexp-boundary</a> (<a id='4931' tid='4932' class='u'>-</a> <a id='4933' tid='4934' class='u'>argument</a>))))
           (<a id='4935' tid='4936' class='u'>goto-char</a> <a id='4937' tid='4938' class='u'>saved</a>)
           (<a id='4939' tid='4940' class='u'>paredit-ignore-sexp-errors</a> (<a id='4941' tid='4942' class='u'>backward-sexp</a> <a id='4943' tid='4944' class='u'>argument</a>))
           (<a id='4945' tid='4946' class='u'>paredit-hack-kill-region</a> <a id='4947' tid='4948' class='u'>saved</a> (<a id='4949' tid='4950' class='u'>point</a>))))
        ((<a id='4951' tid='4952' class='u'>consp</a> <a id='4953' tid='4954' class='u'>argument</a>)
         (<a id='4955' tid='4956' class='u'>let</a> ((<a id='4957' tid='4958' class='u'>v</a> (<a id='4959' tid='4960' class='u'>car</a> <a id='4961' tid='4962' class='u'>argument</a>)))
           (<a id='4963' tid='4964' class='u'>if</a> (<a id='4965' tid='4966' class='u'>=</a> <a id='4967' tid='4968' class='u'>v</a> <a id='4969' tid='4970' class='u'>4</a>)                  <a id='4971' tid='4972' class='u'>;One `C-u&#39;.
</a>               <a id='4973' tid='4974' class='u'>;; Move backward until we hit the open paren; then
</a>               <a id='4975' tid='4976' class='u'>;; kill that selected region.
</a>               (<a id='4977' tid='4978' class='u'>let</a> ((<a id='4979' tid='4980' class='u'>end</a> (<a id='4981' tid='4982' class='u'>point</a>)))
                 (<a id='4983' tid='4984' class='u'>paredit-ignore-sexp-errors</a>
                   (<a id='4985' tid='4986' class='u'>while</a> (<a id='4987' tid='4988' class='u'>not</a> (<a id='4989' tid='4990' class='u'>bobp</a>))
                     (<a id='4991' tid='4992' class='u'>backward-sexp</a>)))
                 (<a id='4993' tid='4994' class='u'>paredit-hack-kill-region</a> (<a id='4995' tid='4996' class='u'>point</a>) <a id='4997' tid='4998' class='u'>end</a>))
               <a id='4999' tid='5000' class='u'>;; Move forward until we hit the close paren; then
</a>               <a id='5001' tid='5002' class='u'>;; kill that selected region.
</a>               (<a id='5003' tid='5004' class='u'>let</a> ((<a id='5005' tid='5006' class='u'>beginning</a> (<a id='5007' tid='5008' class='u'>point</a>)))
                 (<a id='5009' tid='5010' class='u'>paredit-ignore-sexp-errors</a>
                   (<a id='5011' tid='5012' class='u'>while</a> (<a id='5013' tid='5014' class='u'>not</a> (<a id='5015' tid='5016' class='u'>eobp</a>))
                     (<a id='5017' tid='5018' class='u'>forward-sexp</a>)))
                 (<a id='5019' tid='5020' class='u'>paredit-hack-kill-region</a> <a id='5021' tid='5022' class='u'>beginning</a> (<a id='5023' tid='5024' class='u'>point</a>))))))
        (<a id='5025' tid='5026' class='u'>t</a> (<a id='5027' tid='5028' class='u'>error</a> <a id='5029' tid='5030' class='u'>&quot;Bizarre prefix argument `%s&#39;.&quot;</a> <a id='5031' tid='5032' class='u'>argument</a>))))

(<a id='6163' tid='6164' class='u'>defun</a> <a id='6165' tid='6166' class='u'>paredit-splice-sexp-killing-backward</a> (<a id='6167' tid='6168' class='u'>&optional</a> <a id='6169' tid='6170' class='u'>n</a>)
  <a id='6171' tid='6172' class='u'>&quot;Splice the list the point is on by removing its delimiters, and
  also kill all S-expressions before the point in the current list.
With a prefix argument N, kill only the preceding N S-expressions.&quot;</a>
  (<a id='6173' tid='6174' class='u'>interactive</a> <a id='6175' tid='6176' class='u'>&quot;P&quot;</a>)
  (<a id='6177' tid='6178' class='u'>paredit-splice-sexp</a> (<a id='6179' tid='6180' class='u'>if</a> <a id='6181' tid='6182' class='u'>n</a>
                           (<a id='6183' tid='6184' class='u'>prefix-numeric-value</a> <a id='6185' tid='6186' class='u'>n</a>)
                           <a id='6187' tid='6188' class='u'>&#39;</a>(<a id='6189' tid='6190' class='u'>4</a>))))

(<a id='6191' tid='6192' class='u'>defun</a> <a id='6193' tid='6194' class='u'>paredit-splice-sexp-killing-forward</a> (<a id='6195' tid='6196' class='u'>&optional</a> <a id='6197' tid='6198' class='u'>n</a>)
  <a id='6199' tid='6200' class='u'>&quot;Splice the list the point is on by removing its delimiters, and
  also kill all S-expressions after the point in the current list.
With a prefix argument N, kill only the following N S-expressions.&quot;</a>
  (<a id='6201' tid='6202' class='u'>interactive</a> <a id='6203' tid='6204' class='u'>&quot;P&quot;</a>)
  (<a id='6205' tid='6206' class='u'>paredit-splice-sexp</a> (<a id='6207' tid='6208' class='u'>if</a> <a id='6209' tid='6210' class='u'>n</a>
                           (<a id='6211' tid='6212' class='u'>-</a> (<a id='6213' tid='6214' class='u'>prefix-numeric-value</a> <a id='6215' tid='6216' class='u'>n</a>))
                           <a id='6217' tid='6218' class='u'>&#39;</a>(<a id='6219' tid='6220' class='u'>16</a>))))

(<a id='5707' tid='5708' class='u'>defun</a> <a id='5709' tid='5710' class='u'>paredit-raise-sexp</a> (<a id='5711' tid='5712' class='u'>&optional</a> <a id='5713' tid='5714' class='u'>argument</a>)
  <a id='5715' tid='5716' class='u'>&quot;Raise the following S-expression in a tree, deleting its siblings.
With a prefix argument N, raise the following N S-expressions.  If N
  is negative, raise the preceding N S-expressions.
If the point is on an S-expression, such as a string or a symbol, not
  between them, that S-expression is considered to follow the point.&quot;</a>
  (<a id='5717' tid='5718' class='u'>interactive</a> <a id='5719' tid='5720' class='u'>&quot;P&quot;</a>)
  (<a id='1451' tid='1452' class='m'>save-excursion</a>
    (<a id='1453' tid='1454' class='m'>cond</a> ((<a id='1455' tid='1456' class='m'>paredit-in-string-p</a>)
           (<a id='1457' tid='1458' class='m'>goto-char</a> (<a id='1459' tid='1460' class='m'>car</a> (<a id='1461' tid='1462' class='m'>paredit-string-start+end-points</a>))))
          ((<a id='1463' tid='1464' class='m'>paredit-in-char-p</a>)
           (<a id='1465' tid='1466' class='m'>backward-sexp</a>))
          ((<a id='1467' tid='1468' class='m'>paredit-in-comment-p</a>)
           (<a id='1469' tid='1470' class='m'>error</a> <a id='1471' tid='1472' class='m'>&quot;No S-expression to raise in comment.&quot;</a>)))
    <a id='1473' tid='1474' class='m'>;; Select the S-expressions we want to raise in a buffer substring.
</a>    (<a id='1475' tid='1476' class='m'>let*</a> ((<a id='1477' tid='1478' class='m'>n</a> (<a id='1479' tid='1480' class='m'>prefix-numeric-value</a> <a id='1481' tid='1482' class='m'>argument</a>))
           (<a id='1483' tid='1484' class='m'>bound</a> (<a id='1485' tid='1486' class='m'>scan-sexps</a> (<a id='1487' tid='1488' class='m'>point</a>) <a id='1489' tid='1490' class='m'>n</a>))
           (<a id='1491' tid='1492' class='m'>sexps</a>
            (<a id='1493' tid='1494' class='m'>if</a> (<a id='1495' tid='1496' class='m'>&lt;</a> <a id='1497' tid='1498' class='m'>n</a> <a id='1499' tid='1500' class='m'>0</a>)
                (<a id='1501' tid='1502' class='m'>buffer-substring</a> <a id='1503' tid='1504' class='m'>bound</a> (<a id='1505' tid='1506' class='m'>paredit-point-at-sexp-end</a>))
                (<a id='1507' tid='1508' class='m'>buffer-substring</a> (<a id='1509' tid='1510' class='m'>paredit-point-at-sexp-start</a>) <a id='1511' tid='1512' class='m'>bound</a>))))
      <a id='1513' tid='1514' class='m'>;; Move up to the list we&#39;re raising those S-expressions out of and
</a>      <a id='1515' tid='1516' class='m'>;; delete it.
</a>      (<a id='1517' tid='1518' class='m'>backward-up-list</a>)
      (<a id='1519' tid='1520' class='m'>delete-region</a> (<a id='1521' tid='1522' class='m'>point</a>) (<a id='1523' tid='1524' class='m'>scan-sexps</a> (<a id='1525' tid='1526' class='m'>point</a>) <a id='1527' tid='1528' class='m'>1</a>))
      (<span class='d'>let*</span> ((<a id='1529' tid='1530' class='m'>indent-start</a> (<a id='1531' tid='1532' class='m'>point</a>))
             (<a id='1533' tid='1534' class='m'>indent-end</a> (<a id='1535' tid='1536' class='m'>save-excursion</a> (<a id='1537' tid='1538' class='m'>insert</a> <a id='1539' tid='1540' class='m'>sexps</a>) (<a id='1541' tid='1542' class='m'>point</a>))))
        <span class='d'>(indent-region indent-start indent-end)</span>))))

(<a id='2731' tid='2732' class='u'>defun</a> <a id='2733' tid='2734' class='u'>paredit-convolute-sexp</a> (<a id='2735' tid='2736' class='u'>&optional</a> <a id='2737' tid='2738' class='u'>n</a>)
  <a id='2739' tid='2740' class='u'>&quot;Convolute S-expressions.
Save the S-expressions preceding point and delete them.
Splice the S-expressions following point.
Wrap the enclosing list in a new list prefixed by the saved text.
With a prefix argument N, move up N lists before wrapping.&quot;</a>
  (<a id='2741' tid='2742' class='u'>interactive</a> <a id='2743' tid='2744' class='u'>&quot;p&quot;</a>)
  (<a id='2745' tid='2746' class='u'>paredit-lose-if-not-in-sexp</a> <a id='2747' tid='2748' class='u'>&#39;</a><a id='2749' tid='2750' class='u'>paredit-convolute-sexp</a>)
  (<a id='1543' tid='1544' class='m'>let</a> (<a id='1545' tid='1546' class='m'>open</a> <a id='1547' tid='1548' class='m'>close</a>)                     <a id='1549' tid='1550' class='m'>;++ Is this a good idea?
</a>    (<span class='d'>let</span> ((<a id='1551' tid='1552' class='m'>prefix</a>
           (<a id='1553' tid='1554' class='m'>let</a> ((<a id='1555' tid='1556' class='m'>end</a> (<a id='1557' tid='1558' class='m'>point</a>)))
             (<a id='1559' tid='1560' class='m'>paredit-ignore-sexp-errors</a>
               (<a id='1561' tid='1562' class='m'>while</a> (<a id='1563' tid='1564' class='m'>not</a> (<a id='1565' tid='1566' class='m'>bobp</a>)) (<a id='1567' tid='1568' class='m'>backward-sexp</a>)))
             (<span class='d'>prog1</span> <span class='d'>(buffer-substring (point) end)</span>
               <span class='d'>(backward-up-list)</span>
               (<a id='1569' tid='1570' class='m'>save-excursion</a> (<a id='1571' tid='1572' class='m'>forward-sexp</a>)
                               (<a id='1573' tid='1574' class='m'>setq</a> <a id='1575' tid='1576' class='m'>close</a> (<a id='1577' tid='1578' class='m'>char-before</a>))
                               (<a id='1579' tid='1580' class='m'>backward-delete-char</a> <a id='1581' tid='1582' class='m'>1</a>))
               <span class='d'>(setq open (char-after))</span>
               <span class='d'>(delete-region (point) end)</span>))))
      <span class='d'>(backward-up-list n)</span>
      (<a id='679' tid='680' class='m'>paredit-insert-pair</a> <a id='681' tid='682' class='m'>1</a> <a id='683' tid='684' class='m'>open</a> <a id='685' tid='686' class='m'>close</a> <a id='687' tid='688' class='m'>&#39;</a><a id='689' tid='690' class='m'>goto-char</a>)
      <span class='d'>(insert prefix)</span>
      <span class='d'>(backward-up-list)</span>
      <span class='d'>(paredit-ignore-sexp-errors (indent-sexp))</span>)))

(<a id='6221' tid='6222' class='u'>defun</a> <a id='6223' tid='6224' class='u'>paredit-splice-string</a> (<a id='6225' tid='6226' class='u'>argument</a>)
  (<a id='6227' tid='6228' class='u'>let</a> ((<a id='6229' tid='6230' class='u'>original-point</a> (<a id='6231' tid='6232' class='u'>point</a>))
        (<a id='6233' tid='6234' class='u'>start+end</a> (<a id='6235' tid='6236' class='u'>paredit-string-start+end-points</a>)))
    (<a id='6237' tid='6238' class='u'>let</a> ((<a id='6239' tid='6240' class='u'>start</a> (<a id='6241' tid='6242' class='u'>car</a> <a id='6243' tid='6244' class='u'>start+end</a>))
          (<a id='6245' tid='6246' class='u'>end</a> (<a id='6247' tid='6248' class='u'>cdr</a> <a id='6249' tid='6250' class='u'>start+end</a>)))
      <a id='6251' tid='6252' class='u'>;; START and END both lie before the respective quote
</a>      <a id='6253' tid='6254' class='u'>;; characters, which we want to delete; thus we increment START
</a>      <a id='6255' tid='6256' class='u'>;; by one to extract the string, and we increment END by one to
</a>      <a id='6257' tid='6258' class='u'>;; delete the string.
</a>      (<a id='6259' tid='6260' class='u'>let*</a> ((<a id='6261' tid='6262' class='u'>escaped-string</a>
              (<a id='6263' tid='6264' class='u'>cond</a> ((<a id='6265' tid='6266' class='u'>not</a> (<a id='6267' tid='6268' class='u'>consp</a> <a id='6269' tid='6270' class='u'>argument</a>))
                     (<a id='6271' tid='6272' class='u'>buffer-substring</a> (<a id='6273' tid='6274' class='u'>1+</a> <a id='6275' tid='6276' class='u'>start</a>) <a id='6277' tid='6278' class='u'>end</a>))
                    ((<a id='6279' tid='6280' class='u'>=</a> <a id='6281' tid='6282' class='u'>4</a> (<a id='6283' tid='6284' class='u'>car</a> <a id='6285' tid='6286' class='u'>argument</a>))
                     (<a id='6287' tid='6288' class='u'>buffer-substring</a> <a id='6289' tid='6290' class='u'>original-point</a> <a id='6291' tid='6292' class='u'>end</a>))
                    (<a id='6293' tid='6294' class='u'>t</a>
                     (<a id='6295' tid='6296' class='u'>buffer-substring</a> (<a id='6297' tid='6298' class='u'>1+</a> <a id='6299' tid='6300' class='u'>start</a>) <a id='6301' tid='6302' class='u'>original-point</a>))))
             (<a id='6303' tid='6304' class='u'>unescaped-string</a>
              (<a id='6305' tid='6306' class='u'>paredit-unescape-string</a> <a id='6307' tid='6308' class='u'>escaped-string</a>)))
        (<a id='6309' tid='6310' class='u'>if</a> (<a id='6311' tid='6312' class='u'>not</a> <a id='6313' tid='6314' class='u'>unescaped-string</a>)
            (<a id='6315' tid='6316' class='u'>error</a> <a id='6317' tid='6318' class='u'>&quot;Unspliceable string.&quot;</a>)
          (<a id='6319' tid='6320' class='u'>save-excursion</a>
            (<a id='6321' tid='6322' class='u'>goto-char</a> <a id='6323' tid='6324' class='u'>start</a>)
            (<a id='6325' tid='6326' class='u'>delete-region</a> <a id='6327' tid='6328' class='u'>start</a> (<a id='6329' tid='6330' class='u'>1+</a> <a id='6331' tid='6332' class='u'>end</a>))
            (<a id='6333' tid='6334' class='u'>insert</a> <a id='6335' tid='6336' class='u'>unescaped-string</a>))
          (<a id='6337' tid='6338' class='u'>if</a> (<a id='6339' tid='6340' class='u'>not</a> (<a id='6341' tid='6342' class='u'>and</a> (<a id='6343' tid='6344' class='u'>consp</a> <a id='6345' tid='6346' class='u'>argument</a>)
                        (<a id='6347' tid='6348' class='u'>=</a> <a id='6349' tid='6350' class='u'>4</a> (<a id='6351' tid='6352' class='u'>car</a> <a id='6353' tid='6354' class='u'>argument</a>))))
              (<a id='6355' tid='6356' class='u'>goto-char</a> (<a id='6357' tid='6358' class='u'>-</a> <a id='6359' tid='6360' class='u'>original-point</a> <a id='6361' tid='6362' class='u'>1</a>))))))))

(<a id='6481' tid='6482' class='u'>defun</a> <a id='6483' tid='6484' class='u'>paredit-unescape-string</a> (<a id='6485' tid='6486' class='u'>string</a>)
  (<span class='d'>with-temp-buffer</span>
    <span class='d'>(insert string)</span>
    <span class='d'>(goto-char (point-min))</span>
    (<a id='1583' tid='1584' class='m'>while</a> (<a id='1585' tid='1586' class='m'>and</a> (<a id='1587' tid='1588' class='m'>not</a> (<a id='1589' tid='1590' class='m'>eobp</a>))
                <a id='1591' tid='1592' class='m'>;; nil -&gt; no bound; t -&gt; no errors.
</a>                (<a id='1593' tid='1594' class='m'>search-forward</a> <a id='1595' tid='1596' class='m'>&quot;\\&quot;</a> <a id='1597' tid='1598' class='m'>nil</a> <a id='1599' tid='1600' class='m'>t</a>))
      (<a id='1601' tid='1602' class='m'>delete-char</a> <a id='1603' tid='1604' class='m'>-1</a>)
      (<a id='1605' tid='1606' class='m'>forward-char</a>))
    <span class='d'>(condition-case condition
        (progn (check-parens) (buffer-string))
      (error nil))</span>))

<span class='d'>;;;; Slurpage & Barfage
</span>
(<a id='3855' tid='3856' class='u'>defun</a> <a id='3857' tid='3858' class='u'>paredit-forward-slurp-sexp</a> ()
  <a id='3859' tid='3860' class='u'>&quot;Add the S-expression following the current list into that list
  by moving the closing delimiter.
Automatically reindent the newly slurped S-expression with respect to
  its new enclosing form.
If in a string, move the opening double-quote forward by one
  S-expression and escape any intervening characters as necessary,
  without altering any indentation or formatting.&quot;</a>
  (<a id='3861' tid='3862' class='u'>interactive</a>)
  (<a id='3863' tid='3864' class='u'>save-excursion</a>
    (<a id='3865' tid='3866' class='u'>cond</a> ((<a id='3867' tid='3868' class='u'>or</a> (<a id='3869' tid='3870' class='u'>paredit-in-comment-p</a>)
               (<a id='3871' tid='3872' class='u'>paredit-in-char-p</a>))
           (<a id='3873' tid='3874' class='u'>error</a> <a id='3875' tid='3876' class='u'>&quot;Invalid context for slurping S-expressions.&quot;</a>))
          ((<a id='3877' tid='3878' class='u'>paredit-in-string-p</a>)
           (<a id='3879' tid='3880' class='u'>paredit-forward-slurp-into-string</a>))
          (<a id='3881' tid='3882' class='u'>t</a>
           (<a id='3883' tid='3884' class='u'>paredit-forward-slurp-into-list</a>)))))

(<a id='3805' tid='3806' class='u'>defun</a> <a id='3807' tid='3808' class='u'>paredit-forward-slurp-into-list</a> ()
  (<a id='3809' tid='3810' class='u'>up-list</a>)                             <a id='3811' tid='3812' class='u'>; Up to the end of the list to
</a>  (<span class='d'>let</span> <span class='d'>((close (char-before)))</span>          <span class='d'>;   save and delete the closing
</span>    <span class='d'>(backward-delete-char 1)</span>            <span class='d'>;   delimiter.
</span>    (<a id='1607' tid='1608' class='m'>catch</a> <a id='1609' tid='1610' class='m'>&#39;</a><a id='1611' tid='1612' class='m'>return</a>                      <a id='1613' tid='1614' class='m'>; Go to the end of the desired
</a>      (<a id='1615' tid='1616' class='m'>while</a> <a id='1617' tid='1618' class='m'>t</a>                          <a id='1619' tid='1620' class='m'>;   S-expression, going up a
</a>        (<span class='d'>paredit-handle-sexp-errors</span>     <span class='d'>;   list if it&#39;s not in this,
</span>            <span class='d'>(progn (paredit-forward-and-indent)
                   (throw &#39;return nil))</span>
          <span class='d'>(up-list)</span>
          (<a id='1621' tid='1622' class='m'>setq</a> <a id='1623' tid='1624' class='m'>close</a>                   <a id='1625' tid='1626' class='m'>; adjusting for mixed
</a>                (<a id='1627' tid='1628' class='m'>prog1</a> (<a id='1629' tid='1630' class='m'>char-before</a>)    <a id='1631' tid='1632' class='m'>;   delimiters as necessary,
</a>                  (<a id='1633' tid='1634' class='m'>backward-delete-char</a> <a id='1635' tid='1636' class='m'>1</a>)
                  (<a id='1637' tid='1638' class='m'>insert</a> <a id='1639' tid='1640' class='m'>close</a>))))))
    <span class='d'>(insert close)</span>))                    <span class='d'>; to insert that delimiter.
</span>
(<a id='3813' tid='3814' class='u'>defun</a> <a id='3815' tid='3816' class='u'>paredit-forward-slurp-into-string</a> ()
  (<a id='3817' tid='3818' class='u'>goto-char</a> (<a id='3819' tid='3820' class='u'>1+</a> (<a id='3821' tid='3822' class='u'>cdr</a> (<a id='3823' tid='3824' class='u'>paredit-string-start+end-points</a>))))
  <a id='3825' tid='3826' class='u'>;; Signal any errors that we might get first, before mucking with the
</a>  <a id='3827' tid='3828' class='u'>;; buffer&#39;s contents.
</a>  (<a id='3829' tid='3830' class='u'>save-excursion</a> (<a id='3831' tid='3832' class='u'>forward-sexp</a>))
  (<a id='3833' tid='3834' class='u'>let</a> ((<a id='3835' tid='3836' class='u'>close</a> (<a id='3837' tid='3838' class='u'>char-before</a>)))
    (<a id='3839' tid='3840' class='u'>backward-delete-char</a> <a id='3841' tid='3842' class='u'>1</a>)
    (<a id='3843' tid='3844' class='u'>paredit-forward-for-quote</a> (<a id='3845' tid='3846' class='u'>save-excursion</a> (<a id='3847' tid='3848' class='u'>forward-sexp</a>) (<a id='3849' tid='3850' class='u'>point</a>)))
    (<a id='3851' tid='3852' class='u'>insert</a> <a id='3853' tid='3854' class='u'>close</a>)))

(<a id='3217' tid='3218' class='u'>defun</a> <a id='3219' tid='3220' class='u'>paredit-forward-barf-sexp</a> ()
  <a id='3221' tid='3222' class='u'>&quot;Remove the last S-expression in the current list from that list
  by moving the closing delimiter.
Automatically reindent the newly barfed S-expression with respect to
  its new enclosing form.&quot;</a>
  (<a id='3223' tid='3224' class='u'>interactive</a>)
  (<a id='3225' tid='3226' class='u'>paredit-lose-if-not-in-sexp</a> <a id='3227' tid='3228' class='u'>&#39;</a><a id='3229' tid='3230' class='u'>paredit-forward-barf-sexp</a>)
  <span class='d'>(save-excursion
    (up-list)                           ; Up to the end of the list to
    (let ((close (char-before)))        ;   save and delete the closing
      (backward-delete-char 1)          ;   delimiter.
      (paredit-ignore-sexp-errors       ; Go back to where we want to
        (backward-sexp))                ;   insert the delimiter.
      (paredit-skip-whitespace nil)     ; Skip leading whitespace.
      (cond ((bobp)
             (error &quot;Barfing all subexpressions with no open-paren?&quot;))
            ((paredit-in-comment-p)     ; Don&#39;t put the close-paren in
             (newline-and-indent)))     ;   a comment.
      (insert close))
    ;; Reindent all of the newly barfed S-expressions.
    (paredit-forward-and-indent))</span>)

(<a id='2511' tid='2512' class='u'>defun</a> <a id='2513' tid='2514' class='u'>paredit-backward-slurp-sexp</a> ()
  <a id='2515' tid='2516' class='u'>&quot;Add the S-expression preceding the current list into that list
  by moving the closing delimiter.
Automatically reindent the whole form into which new S-expression was
  slurped.
If in a string, move the opening double-quote backward by one
  S-expression and escape any intervening characters as necessary,
  without altering any indentation or formatting.&quot;</a>
  (<a id='2517' tid='2518' class='u'>interactive</a>)
  (<a id='2519' tid='2520' class='u'>save-excursion</a>
    (<a id='2521' tid='2522' class='u'>cond</a> ((<a id='2523' tid='2524' class='u'>or</a> (<a id='2525' tid='2526' class='u'>paredit-in-comment-p</a>)
               (<a id='2527' tid='2528' class='u'>paredit-in-char-p</a>))
           (<a id='2529' tid='2530' class='u'>error</a> <a id='2531' tid='2532' class='u'>&quot;Invalid context for slurping S-expressions.&quot;</a>))
          ((<a id='2533' tid='2534' class='u'>paredit-in-string-p</a>)
           (<a id='2535' tid='2536' class='u'>paredit-backward-slurp-into-string</a>))
          (<a id='2537' tid='2538' class='u'>t</a>
           (<a id='2539' tid='2540' class='u'>paredit-backward-slurp-into-list</a>)))))

(<a id='2395' tid='2396' class='u'>defun</a> <a id='2397' tid='2398' class='u'>paredit-backward-slurp-into-list</a> ()
  (<a id='2399' tid='2400' class='u'>backward-up-list</a>)
  (<a id='2401' tid='2402' class='u'>let</a> ((<a id='2403' tid='2404' class='u'>open</a> (<a id='2405' tid='2406' class='u'>char-after</a>)))
    (<a id='2407' tid='2408' class='u'>delete-char</a> <a id='2409' tid='2410' class='u'>1</a>)
    (<a id='2411' tid='2412' class='u'>catch</a> <a id='2413' tid='2414' class='u'>&#39;</a><a id='2415' tid='2416' class='u'>return</a>
      (<a id='2417' tid='2418' class='u'>while</a> <a id='2419' tid='2420' class='u'>t</a>
        (<a id='2421' tid='2422' class='u'>paredit-handle-sexp-errors</a>
            (<a id='2423' tid='2424' class='u'>progn</a> (<a id='2425' tid='2426' class='u'>backward-sexp</a>) (<a id='2427' tid='2428' class='u'>throw</a> <a id='2429' tid='2430' class='u'>&#39;</a><a id='2431' tid='2432' class='u'>return</a> <a id='2433' tid='2434' class='u'>nil</a>))
          (<a id='2435' tid='2436' class='u'>backward-up-list</a>)
          (<a id='2437' tid='2438' class='u'>setq</a> <a id='2439' tid='2440' class='u'>open</a>
                (<a id='2441' tid='2442' class='u'>prog1</a> (<a id='2443' tid='2444' class='u'>char-after</a>)
                  (<a id='2445' tid='2446' class='u'>save-excursion</a> (<a id='2447' tid='2448' class='u'>insert</a> <a id='2449' tid='2450' class='u'>open</a>) (<a id='2451' tid='2452' class='u'>delete-char</a> <a id='2453' tid='2454' class='u'>1</a>)))))))
    (<a id='2455' tid='2456' class='u'>insert</a> <a id='2457' tid='2458' class='u'>open</a>))
  <a id='2459' tid='2460' class='u'>;; Reindent the line at the beginning of wherever we inserted the
</a>  <a id='2461' tid='2462' class='u'>;; opening delimiter, and then indent the whole S-expression.
</a>  (<a id='2463' tid='2464' class='u'>backward-up-list</a>)
  (<a id='2465' tid='2466' class='u'>lisp-indent-line</a>)
  (<a id='2467' tid='2468' class='u'>indent-sexp</a>))

(<a id='2469' tid='2470' class='u'>defun</a> <a id='2471' tid='2472' class='u'>paredit-backward-slurp-into-string</a> ()
  (<a id='2473' tid='2474' class='u'>goto-char</a> (<a id='2475' tid='2476' class='u'>car</a> (<a id='2477' tid='2478' class='u'>paredit-string-start+end-points</a>)))
  <a id='2479' tid='2480' class='u'>;; Signal any errors that we might get first, before mucking with the
</a>  <a id='2481' tid='2482' class='u'>;; buffer&#39;s contents.
</a>  (<a id='2483' tid='2484' class='u'>save-excursion</a> (<a id='2485' tid='2486' class='u'>backward-sexp</a>))
  (<a id='2487' tid='2488' class='u'>let</a> ((<a id='2489' tid='2490' class='u'>open</a> (<a id='2491' tid='2492' class='u'>char-after</a>))
        (<a id='2493' tid='2494' class='u'>target</a> (<a id='2495' tid='2496' class='u'>point</a>)))
    (<a id='2497' tid='2498' class='u'>delete-char</a> <a id='2499' tid='2500' class='u'>1</a>)
    (<a id='2501' tid='2502' class='u'>backward-sexp</a>)
    (<a id='2503' tid='2504' class='u'>insert</a> <a id='2505' tid='2506' class='u'>open</a>)
    (<a id='2507' tid='2508' class='u'>paredit-forward-for-quote</a> <a id='2509' tid='2510' class='u'>target</a>)))

(<a id='2033' tid='2034' class='u'>defun</a> <a id='2035' tid='2036' class='u'>paredit-backward-barf-sexp</a> ()
  <a id='2037' tid='2038' class='u'>&quot;Remove the first S-expression in the current list from that list
  by moving the closing delimiter.
Automatically reindent the barfed S-expression and the form from which
  it was barfed.&quot;</a>
  (<a id='2039' tid='2040' class='u'>interactive</a>)
  (<a id='2041' tid='2042' class='u'>paredit-lose-if-not-in-sexp</a> <a id='2043' tid='2044' class='u'>&#39;</a><a id='2045' tid='2046' class='u'>paredit-backward-barf-sexp</a>)
  (<a id='2047' tid='2048' class='u'>save-excursion</a>
    (<a id='2049' tid='2050' class='u'>backward-up-list</a>)
    (<a id='2051' tid='2052' class='u'>let</a> ((<a id='2053' tid='2054' class='u'>open</a> (<a id='2055' tid='2056' class='u'>char-after</a>)))
      (<a id='2057' tid='2058' class='u'>delete-char</a> <a id='2059' tid='2060' class='u'>1</a>)
      (<a id='2061' tid='2062' class='u'>paredit-ignore-sexp-errors</a>
        (<a id='2063' tid='2064' class='u'>paredit-forward-and-indent</a>))
      (<a id='2065' tid='2066' class='u'>while</a> (<a id='2067' tid='2068' class='u'>progn</a> (<a id='2069' tid='2070' class='u'>paredit-skip-whitespace</a> <a id='2071' tid='2072' class='u'>t</a>)
                    (<a id='2073' tid='2074' class='u'>eq</a> (<a id='2075' tid='2076' class='u'>char-after</a>) <a id='2077' tid='2078' class='u'>?\;</a> ))
        (<a id='2079' tid='2080' class='u'>forward-line</a> <a id='2081' tid='2082' class='u'>1</a>))
      (<a id='2083' tid='2084' class='u'>if</a> (<a id='2085' tid='2086' class='u'>eobp</a>)
          (<a id='2087' tid='2088' class='u'>error</a> <a id='2089' tid='2090' class='u'>&quot;Barfing all subexpressions with no close-paren?&quot;</a>))
      <a id='2091' tid='2092' class='u'>;** Don&#39;t use `insert&#39; here.  Consider, e.g., barfing from
</a>      <a id='2093' tid='2094' class='u'>;**   (foo|)
</a>      <a id='2095' tid='2096' class='u'>;** and how `save-excursion&#39; works.
</a>      (<a id='2097' tid='2098' class='u'>insert-before-markers</a> <a id='2099' tid='2100' class='u'>open</a>))
    (<a id='2101' tid='2102' class='u'>backward-up-list</a>)
    (<a id='2103' tid='2104' class='u'>lisp-indent-line</a>)
    (<a id='2105' tid='2106' class='u'>indent-sexp</a>)))

<span class='d'>;;;; Splitting & Joining
</span>
(<a id='6363' tid='6364' class='u'>defun</a> <a id='6365' tid='6366' class='u'>paredit-split-sexp</a> ()
  <a id='6367' tid='6368' class='u'>&quot;Split the list or string the point is on into two.&quot;</a>
  (<a id='6369' tid='6370' class='u'>interactive</a>)
  (<a id='6371' tid='6372' class='u'>cond</a> ((<a id='6373' tid='6374' class='u'>paredit-in-string-p</a>)
         (<a id='6375' tid='6376' class='u'>insert</a> <a id='6377' tid='6378' class='u'>&quot;\&quot;&quot;</a>)
         (<a id='6379' tid='6380' class='u'>save-excursion</a> (<a id='6381' tid='6382' class='u'>insert</a> <a id='6383' tid='6384' class='u'>&quot; \&quot;&quot;</a>)))
        ((<a id='6385' tid='6386' class='u'>or</a> (<a id='6387' tid='6388' class='u'>paredit-in-comment-p</a>)
             (<a id='6389' tid='6390' class='u'>paredit-in-char-p</a>))
         (<a id='6391' tid='6392' class='u'>error</a> <a id='6393' tid='6394' class='u'>&quot;Invalid context for splitting S-expression.&quot;</a>))
        (<a id='6395' tid='6396' class='u'>t</a> (<a id='6397' tid='6398' class='u'>let</a> ((<a id='6399' tid='6400' class='u'>open</a>  (<a id='6401' tid='6402' class='u'>save-excursion</a> (<a id='6403' tid='6404' class='u'>backward-up-list</a>)
                                        (<a id='6405' tid='6406' class='u'>char-after</a>)))
                 (<a id='6407' tid='6408' class='u'>close</a> (<a id='6409' tid='6410' class='u'>save-excursion</a> (<a id='6411' tid='6412' class='u'>up-list</a>)
                                        (<a id='6413' tid='6414' class='u'>char-before</a>))))
             (<a id='6415' tid='6416' class='u'>delete-horizontal-space</a>)
             (<a id='6417' tid='6418' class='u'>insert</a> <a id='6419' tid='6420' class='u'>close</a>)
             (<a id='6421' tid='6422' class='u'>save-excursion</a> (<a id='6423' tid='6424' class='u'>insert</a> <a id='6425' tid='6426' class='u'>?\ </a>)
                             (<a id='6427' tid='6428' class='u'>insert</a> <a id='6429' tid='6430' class='u'>open</a>)
                             (<a id='6431' tid='6432' class='u'>backward-char</a>)
                             (<a id='6433' tid='6434' class='u'>indent-sexp</a>))))))

(<a id='4477' tid='4478' class='u'>defun</a> <a id='4479' tid='4480' class='u'>paredit-join-sexps</a> ()
  <a id='4481' tid='4482' class='u'>&quot;Join the S-expressions adjacent on either side of the point.
Both must be lists, strings, or atoms; error if there is a mismatch.&quot;</a>
  (<a id='4483' tid='4484' class='u'>interactive</a>)
  <a id='4485' tid='4486' class='u'>;++ How ought this to handle comments intervening symbols or strings?
</a>  (<a id='1641' tid='1642' class='m'>save-excursion</a>
    (<a id='1643' tid='1644' class='m'>if</a> (<a id='1645' tid='1646' class='m'>or</a> (<a id='1647' tid='1648' class='m'>paredit-in-comment-p</a>)
            (<a id='1649' tid='1650' class='m'>paredit-in-string-p</a>)
            (<a id='1651' tid='1652' class='m'>paredit-in-char-p</a>))
        (<a id='1653' tid='1654' class='m'>error</a> <a id='1655' tid='1656' class='m'>&quot;Invalid context for joining S-expressions.&quot;</a>)
      (<a id='1657' tid='1658' class='m'>let</a> ((<a id='1659' tid='1660' class='m'>left-point</a>  (<a id='1661' tid='1662' class='m'>paredit-point-at-sexp-end</a>))
            (<a id='1663' tid='1664' class='m'>right-point</a> (<a id='1665' tid='1666' class='m'>paredit-point-at-sexp-start</a>)))
        (<a id='1667' tid='1668' class='m'>let</a> ((<a id='1669' tid='1670' class='m'>left-char</a> (<a id='1671' tid='1672' class='m'>char-before</a> <a id='1673' tid='1674' class='m'>left-point</a>))
              (<a id='1675' tid='1676' class='m'>right-char</a> (<a id='1677' tid='1678' class='m'>char-after</a> <a id='1679' tid='1680' class='m'>right-point</a>)))
          (<a id='1681' tid='1682' class='m'>let</a> ((<a id='1683' tid='1684' class='m'>left-syntax</a> (<a id='1685' tid='1686' class='m'>char-syntax</a> <a id='1687' tid='1688' class='m'>left-char</a>))
                (<a id='1689' tid='1690' class='m'>right-syntax</a> (<a id='1691' tid='1692' class='m'>char-syntax</a> <a id='1693' tid='1694' class='m'>right-char</a>)))
            (<span class='d'>cond</span> <span class='d'>((&gt;= left-point right-point)
                   (error &quot;Can&#39;t join a datum with itself.&quot;))</span>
                  ((<a id='1695' tid='1696' class='m'>and</a> (<a id='1697' tid='1698' class='m'>eq</a> <a id='1699' tid='1700' class='m'>left-syntax</a>  <a id='1701' tid='1702' class='m'>?\)</a> )
                        (<a id='1703' tid='1704' class='m'>eq</a> <a id='1705' tid='1706' class='m'>right-syntax</a> <a id='1707' tid='1708' class='m'>?\(</a> )
                        (<a id='1709' tid='1710' class='m'>eq</a> <a id='1711' tid='1712' class='m'>left-char</a> (<a id='1713' tid='1714' class='m'>matching-paren</a> <a id='1715' tid='1716' class='m'>right-char</a>))
                        (<a id='1717' tid='1718' class='m'>eq</a> <a id='1719' tid='1720' class='m'>right-char</a> (<a id='1721' tid='1722' class='m'>matching-paren</a> <a id='1723' tid='1724' class='m'>left-char</a>)))
                   <span class='d'>;; Leave intermediate formatting alone.
</span>                   <span class='d'>(goto-char right-point)</span>
                   <span class='d'>(delete-char 1)</span>
                   <span class='d'>(goto-char left-point)</span>
                   <span class='d'>(backward-delete-char 1)</span>
                   <span class='d'>(backward-up-list)</span>
                   <span class='d'>(indent-sexp)</span>)
                  ((<a id='691' tid='692' class='m'>and</a> (<a id='693' tid='694' class='m'>eq</a> <a id='695' tid='696' class='m'>left-syntax</a>  <a id='697' tid='698' class='m'>?\&quot;</a> )
                        (<a id='699' tid='700' class='m'>eq</a> <a id='701' tid='702' class='m'>right-syntax</a> <a id='703' tid='704' class='m'>?\&quot;</a> ))
                   <a id='705' tid='706' class='m'>;; Delete any intermediate formatting.
</a>                   (<a id='707' tid='708' class='m'>delete-region</a> (<a id='709' tid='710' class='m'>1-</a> <a id='711' tid='712' class='m'>left-point</a>)
                                  (<a id='713' tid='714' class='m'>1+</a> <a id='715' tid='716' class='m'>right-point</a>)))
                  ((<a id='495' tid='496' class='m'>and</a> (<a id='497' tid='498' class='m'>memq</a> <a id='499' tid='500' class='m'>left-syntax</a>  <a id='501' tid='502' class='m'>&#39;</a>(<a id='503' tid='504' class='m'>?w</a> <a id='505' tid='506' class='m'>?_</a>)) <a id='507' tid='508' class='m'>; Word or symbol
</a>                        (<a id='509' tid='510' class='m'>memq</a> <a id='511' tid='512' class='m'>right-syntax</a> <a id='513' tid='514' class='m'>&#39;</a>(<a id='515' tid='516' class='m'>?w</a> <a id='517' tid='518' class='m'>?_</a>)))
                   (<a id='519' tid='520' class='m'>delete-region</a> <a id='521' tid='522' class='m'>left-point</a> <a id='523' tid='524' class='m'>right-point</a>))
                  <span class='d'>(t
                   (error &quot;Mismatched S-expressions to join.&quot;))</span>)))))))

<span class='d'>;;;; Variations on the Lurid Theme
</span>
<span class='d'>;;; I haven&#39;t the imagination to concoct clever names for these.
</span>
(<a id='1809' tid='1810' class='u'>defun</a> <a id='1811' tid='1812' class='u'>paredit-add-to-previous-list</a> ()
  <a id='1813' tid='1814' class='u'>&quot;Add the S-expression following point to the list preceding point.&quot;</a>
  (<a id='1815' tid='1816' class='u'>interactive</a>)
  (<a id='1817' tid='1818' class='u'>paredit-lose-if-not-in-sexp</a> <a id='1819' tid='1820' class='u'>&#39;</a><a id='1821' tid='1822' class='u'>paredit-add-to-previous-list</a>)
  (<a id='1823' tid='1824' class='u'>save-excursion</a>
    (<a id='1825' tid='1826' class='u'>backward-down-list</a>)
    (<a id='1827' tid='1828' class='u'>paredit-forward-slurp-sexp</a>)))

(<a id='1789' tid='1790' class='u'>defun</a> <a id='1791' tid='1792' class='u'>paredit-add-to-next-list</a> ()
  <a id='1793' tid='1794' class='u'>&quot;Add the S-expression preceding point to the list following point.
If no S-expression precedes point, move up the tree until one does.&quot;</a>
  (<a id='1795' tid='1796' class='u'>interactive</a>)
  (<a id='1797' tid='1798' class='u'>paredit-lose-if-not-in-sexp</a> <a id='1799' tid='1800' class='u'>&#39;</a><a id='1801' tid='1802' class='u'>paredit-add-to-next-list</a>)
  (<a id='1803' tid='1804' class='u'>save-excursion</a>
    (<a id='1805' tid='1806' class='u'>down-list</a>)
    (<a id='1807' tid='1808' class='u'>paredit-backward-slurp-sexp</a>)))

(<a id='4519' tid='4520' class='u'>defun</a> <a id='4521' tid='4522' class='u'>paredit-join-with-previous-list</a> ()
  <a id='4523' tid='4524' class='u'>&quot;Join the list the point is on with the previous list in the buffer.&quot;</a>
  (<a id='4525' tid='4526' class='u'>interactive</a>)
  (<a id='4527' tid='4528' class='u'>paredit-lose-if-not-in-sexp</a> <a id='4529' tid='4530' class='u'>&#39;</a><a id='4531' tid='4532' class='u'>paredit-join-with-previous-list</a>)
  (<a id='4533' tid='4534' class='u'>save-excursion</a>
    (<a id='4535' tid='4536' class='u'>while</a> (<a id='4537' tid='4538' class='u'>paredit-handle-sexp-errors</a> (<a id='4539' tid='4540' class='u'>save-excursion</a> (<a id='4541' tid='4542' class='u'>backward-sexp</a>) <a id='4543' tid='4544' class='u'>nil</a>)
             (<a id='4545' tid='4546' class='u'>backward-up-list</a>)
             <a id='4547' tid='4548' class='u'>t</a>))
    (<a id='4549' tid='4550' class='u'>paredit-join-sexps</a>)))

(<a id='4487' tid='4488' class='u'>defun</a> <a id='4489' tid='4490' class='u'>paredit-join-with-next-list</a> ()
  <a id='4491' tid='4492' class='u'>&quot;Join the list the point is on with the next list in the buffer.&quot;</a>
  (<a id='4493' tid='4494' class='u'>interactive</a>)
  (<a id='4495' tid='4496' class='u'>paredit-lose-if-not-in-sexp</a> <a id='4497' tid='4498' class='u'>&#39;</a><a id='4499' tid='4500' class='u'>paredit-join-with-next-list</a>)
  (<a id='4501' tid='4502' class='u'>save-excursion</a>
    (<a id='4503' tid='4504' class='u'>while</a> (<a id='4505' tid='4506' class='u'>paredit-handle-sexp-errors</a> (<a id='4507' tid='4508' class='u'>save-excursion</a> (<a id='4509' tid='4510' class='u'>forward-sexp</a>) <a id='4511' tid='4512' class='u'>nil</a>)
             (<a id='4513' tid='4514' class='u'>up-list</a>)
             <a id='4515' tid='4516' class='u'>t</a>))
    (<a id='4517' tid='4518' class='u'>paredit-join-sexps</a>)))

<span class='d'>;;;; Utilities
</span>
(<a id='4105' tid='4106' class='u'>defun</a> <a id='4107' tid='4108' class='u'>paredit-in-string-escape-p</a> ()
  <a id='4109' tid='4110' class='u'>&quot;True if the point is on a character escape of a string.
This is true only if the character is preceded by an odd number of
  backslashes.
This assumes that `paredit-in-string-p&#39; has already returned true.&quot;</a>
  (<a id='4111' tid='4112' class='u'>let</a> ((<a id='4113' tid='4114' class='u'>oddp</a> <a id='4115' tid='4116' class='u'>nil</a>))
    (<a id='4117' tid='4118' class='u'>save-excursion</a>
      (<a id='4119' tid='4120' class='u'>while</a> (<a id='4121' tid='4122' class='u'>eq</a> (<a id='4123' tid='4124' class='u'>char-before</a>) <a id='4125' tid='4126' class='u'>?\\</a> )
        (<a id='4127' tid='4128' class='u'>setq</a> <a id='4129' tid='4130' class='u'>oddp</a> (<a id='4131' tid='4132' class='u'>not</a> <a id='4133' tid='4134' class='u'>oddp</a>))
        (<a id='4135' tid='4136' class='u'>backward-char</a>)))
    <a id='4137' tid='4138' class='u'>oddp</a>))

(<a id='4073' tid='4074' class='u'>defun</a> <a id='4075' tid='4076' class='u'>paredit-in-char-p</a> <span class='d'>(&optional argument)</span>
  <span class='d'>&quot;True if the point is immediately after a character literal.
A preceding escape character, not preceded by another escape character,
  is considered a character literal prefix.  (This works for elisp,
  Common Lisp, and Scheme.)
Assumes that `paredit-in-string-p&#39; is false, so that it need not handle
  long sequences of preceding backslashes in string escapes.  (This
  assumes some other leading character token -- ? in elisp, # in Scheme
  and Common Lisp.)&quot;</span>
  <span class='d'>(let ((argument (or argument (point))))
    (and (eq (char-before argument) ?\\ )
         (not (eq (char-before (1- argument)) ?\\ ))))</span>)

(<a id='4165' tid='4166' class='u'>defun</a> <a id='4167' tid='4168' class='u'>paredit-indent-sexps</a> ()
  <a id='4169' tid='4170' class='u'>&quot;If in a list, indent all following S-expressions in the list.&quot;</a>
  (<span class='d'>let</span> ((<a id='1725' tid='1726' class='m'>start</a> (<a id='1727' tid='1728' class='m'>point</a>))
        (<a id='1729' tid='1730' class='m'>end</a> (<a id='1731' tid='1732' class='m'>paredit-handle-sexp-errors</a> (<a id='1733' tid='1734' class='m'>progn</a> (<a id='1735' tid='1736' class='m'>up-list</a>) (<a id='1737' tid='1738' class='m'>point</a>)) <a id='1739' tid='1740' class='m'>nil</a>)))
    <span class='d'>(if end
        (indent-region start end))</span>))

(<a id='3211' tid='3212' class='u'>defun</a> <a id='3213' tid='3214' class='u'>paredit-forward-and-indent</a> ()
  <a id='3215' tid='3216' class='u'>&quot;Move forward an S-expression, indenting it with `indent-region&#39;.&quot;</a>
  <span class='d'>(let ((start (point)))
    (forward-sexp)
    (indent-region start (point)))</span>)

(<a id='5995' tid='5996' class='u'>defun</a> <a id='5997' tid='5998' class='u'>paredit-skip-whitespace</a> (<a id='5999' tid='6000' class='u'>trailing-p</a> <a id='6001' tid='6002' class='u'>&optional</a> <a id='6003' tid='6004' class='u'>limit</a>)
  <a id='6005' tid='6006' class='u'>&quot;Skip past any whitespace, or until the point LIMIT is reached.
If TRAILING-P is nil, skip leading whitespace; otherwise, skip trailing
  whitespace.&quot;</a>
  (<a id='6007' tid='6008' class='u'>funcall</a> (<a id='6009' tid='6010' class='u'>if</a> <a id='6011' tid='6012' class='u'>trailing-p</a> <a id='6013' tid='6014' class='u'>&#39;</a><a id='6015' tid='6016' class='u'>skip-chars-forward</a> <a id='6017' tid='6018' class='u'>&#39;</a><a id='6019' tid='6020' class='u'>skip-chars-backward</a>)
           <a id='6021' tid='6022' class='u'>&quot; \t\n&quot;</a>  <a id='6023' tid='6024' class='u'>; This should skip using the syntax table, but LF
</a>           <a id='6025' tid='6026' class='u'>limit</a>))    <span class='d'>; is a comment end, not newline, in Lisp mode.
</span>
(<a id='7463' tid='7464' class='u'>defalias</a> <a id='7465' tid='7466' class='u'>&#39;</a><a id='7467' tid='7468' class='u'>paredit-region-active-p</a>
  (<a id='7469' tid='7470' class='u'>xcond</a> ((<a id='7471' tid='7472' class='u'>paredit-xemacs-p</a>) <a id='7473' tid='7474' class='u'>&#39;</a><a id='7475' tid='7476' class='u'>region-active-p</a>)
         ((<a id='7477' tid='7478' class='u'>paredit-gnu-emacs-p</a>)
          (<a id='7479' tid='7480' class='u'>lambda</a> ()
            (<a id='7481' tid='7482' class='u'>and</a> <a id='7483' tid='7484' class='u'>mark-active</a> <a id='7485' tid='7486' class='u'>transient-mark-mode</a>)))))

(<a id='3955' tid='3956' class='u'>defun</a> <a id='3957' tid='3958' class='u'>paredit-hack-kill-region</a> (<a id='3959' tid='3960' class='u'>start</a> <a id='3961' tid='3962' class='u'>end</a>)
  <a id='3963' tid='3964' class='u'>&quot;Kill the region between START and END.
Do not append to any current kill, and
 do not let the next kill append to this one.&quot;</a>
  (<a id='3965' tid='3966' class='u'>interactive</a> <a id='3967' tid='3968' class='u'>&quot;r&quot;</a>)                     <a id='3969' tid='3970' class='u'>;Eh, why not?
</a>  <a id='3971' tid='3972' class='u'>;; KILL-REGION sets THIS-COMMAND to tell the next kill that the last
</a>  <a id='3973' tid='3974' class='u'>;; command was a kill.  It also checks LAST-COMMAND to see whether it
</a>  <a id='3975' tid='3976' class='u'>;; should append.  If we bind these locally, any modifications to
</a>  <a id='3977' tid='3978' class='u'>;; THIS-COMMAND will be masked, and it will not see LAST-COMMAND to
</a>  <a id='3979' tid='3980' class='u'>;; indicate that it should append.
</a>  (<a id='3981' tid='3982' class='u'>let</a> ((<a id='3983' tid='3984' class='u'>this-command</a> <a id='3985' tid='3986' class='u'>nil</a>)
        (<a id='3987' tid='3988' class='u'>last-command</a> <a id='3989' tid='3990' class='u'>nil</a>))
    (<a id='3991' tid='3992' class='u'>kill-region</a> <a id='3993' tid='3994' class='u'>start</a> <a id='3995' tid='3996' class='u'>end</a>)))

<a id='7487' tid='7488' class='u'>;;;;; S-expression Parsing Utilities
</a>
<a id='7489' tid='7490' class='u'>;++ These routines redundantly traverse S-expressions a great deal.
</a><a id='7491' tid='7492' class='u'>;++ If performance issues arise, this whole section will probably have
</a><a id='7493' tid='7494' class='u'>;++ to be refactored to preserve the state longer, like paredit.scm
</a><a id='7495' tid='7496' class='u'>;++ does, rather than to traverse the definition N times for every key
</a><a id='7497' tid='7498' class='u'>;++ stroke as it presently does.
</a>
(<a id='2931' tid='2932' class='u'>defun</a> <a id='2933' tid='2934' class='u'>paredit-current-parse-state</a> ()
  <a id='2935' tid='2936' class='u'>&quot;Return parse state of point from beginning of defun.&quot;</a>
  (<a id='2937' tid='2938' class='u'>let</a> ((<a id='2939' tid='2940' class='u'>point</a> (<a id='2941' tid='2942' class='u'>point</a>)))
    (<a id='2943' tid='2944' class='u'>beginning-of-defun</a>)
    <a id='2945' tid='2946' class='u'>;; Calling PARSE-PARTIAL-SEXP will advance the point to its second
</a>    <a id='2947' tid='2948' class='u'>;; argument (unless parsing stops due to an error, but we assume it
</a>    <a id='2949' tid='2950' class='u'>;; won&#39;t in paredit-mode).
</a>    (<a id='2951' tid='2952' class='u'>parse-partial-sexp</a> (<a id='2953' tid='2954' class='u'>point</a>) <a id='2955' tid='2956' class='u'>point</a>)))

(<a id='4139' tid='4140' class='u'>defun</a> <a id='4141' tid='4142' class='u'>paredit-in-string-p</a> (<a id='4143' tid='4144' class='u'>&optional</a> <a id='4145' tid='4146' class='u'>state</a>)
  <a id='4147' tid='4148' class='u'>&quot;True if the parse state is within a double-quote-delimited string.
If no parse state is supplied, compute one from the beginning of the
  defun to the point.&quot;</a>
  <a id='4149' tid='4150' class='u'>;; 3. non-nil if inside a string (the terminator character, really)
</a>  (<a id='4151' tid='4152' class='u'>and</a> (<a id='4153' tid='4154' class='u'>nth</a> <a id='4155' tid='4156' class='u'>3</a> (<a id='4157' tid='4158' class='u'>or</a> <a id='4159' tid='4160' class='u'>state</a> (<a id='4161' tid='4162' class='u'>paredit-current-parse-state</a>)))
       <a id='4163' tid='4164' class='u'>t</a>))

(<a id='6435' tid='6436' class='u'>defun</a> <a id='6437' tid='6438' class='u'>paredit-string-start+end-points</a> (<a id='6439' tid='6440' class='u'>&optional</a> <a id='6441' tid='6442' class='u'>state</a>)
  <a id='6443' tid='6444' class='u'>&quot;Return a cons of the points of open and close quotes of the string.
The string is determined from the parse state STATE, or the parse state
  from the beginning of the defun to the point.
This assumes that `paredit-in-string-p&#39; has already returned true, i.e.
  that the point is already within a string.&quot;</a>
  (<a id='6445' tid='6446' class='u'>save-excursion</a>
    <a id='6447' tid='6448' class='u'>;; 8. character address of start of comment or string; nil if not
</a>    <a id='6449' tid='6450' class='u'>;;    in one
</a>    (<a id='6451' tid='6452' class='u'>let</a> ((<a id='6453' tid='6454' class='u'>start</a> (<a id='6455' tid='6456' class='u'>nth</a> <a id='6457' tid='6458' class='u'>8</a> (<a id='6459' tid='6460' class='u'>or</a> <a id='6461' tid='6462' class='u'>state</a> (<a id='6463' tid='6464' class='u'>paredit-current-parse-state</a>)))))
      (<a id='6465' tid='6466' class='u'>goto-char</a> <a id='6467' tid='6468' class='u'>start</a>)
      (<a id='6469' tid='6470' class='u'>forward-sexp</a> <a id='6471' tid='6472' class='u'>1</a>)
      (<a id='6473' tid='6474' class='u'>cons</a> <a id='6475' tid='6476' class='u'>start</a> (<a id='6477' tid='6478' class='u'>1-</a> (<a id='6479' tid='6480' class='u'>point</a>))))))

(<a id='4077' tid='4078' class='u'>defun</a> <a id='4079' tid='4080' class='u'>paredit-in-comment-p</a> (<a id='4081' tid='4082' class='u'>&optional</a> <a id='4083' tid='4084' class='u'>state</a>)
  <a id='4085' tid='4086' class='u'>&quot;True if parse state STATE is within a comment.
If no parse state is supplied, compute one from the beginning of the
  defun to the point.&quot;</a>
  <a id='4087' tid='4088' class='u'>;; 4. nil if outside a comment, t if inside a non-nestable comment,
</a>  <a id='4089' tid='4090' class='u'>;;    else an integer (the current comment nesting)
</a>  (<a id='4091' tid='4092' class='u'>and</a> (<a id='4093' tid='4094' class='u'>nth</a> <a id='4095' tid='4096' class='u'>4</a> (<a id='4097' tid='4098' class='u'>or</a> <a id='4099' tid='4100' class='u'>state</a> (<a id='4101' tid='4102' class='u'>paredit-current-parse-state</a>)))
       <a id='4103' tid='4104' class='u'>t</a>))

(<a id='5651' tid='5652' class='u'>defun</a> <a id='5653' tid='5654' class='u'>paredit-point-at-sexp-boundary</a> (<a id='5655' tid='5656' class='u'>n</a>)
  (<a id='5657' tid='5658' class='u'>cond</a> ((<a id='5659' tid='5660' class='u'>&lt;</a> <a id='5661' tid='5662' class='u'>n</a> <a id='5663' tid='5664' class='u'>0</a>) (<a id='5665' tid='5666' class='u'>paredit-point-at-sexp-start</a>))
        ((<a id='5667' tid='5668' class='u'>=</a> <a id='5669' tid='5670' class='u'>n</a> <a id='5671' tid='5672' class='u'>0</a>) (<a id='5673' tid='5674' class='u'>point</a>))
        ((<a id='5675' tid='5676' class='u'>&gt;</a> <a id='5677' tid='5678' class='u'>n</a> <a id='5679' tid='5680' class='u'>0</a>) (<a id='5681' tid='5682' class='u'>paredit-point-at-sexp-end</a>))))

(<a id='5695' tid='5696' class='u'>defun</a> <a id='5697' tid='5698' class='u'>paredit-point-at-sexp-start</a> ()
  (<a id='5699' tid='5700' class='u'>save-excursion</a>
    (<a id='5701' tid='5702' class='u'>forward-sexp</a>)
    (<a id='5703' tid='5704' class='u'>backward-sexp</a>)
    (<a id='5705' tid='5706' class='u'>point</a>)))

(<a id='5683' tid='5684' class='u'>defun</a> <a id='5685' tid='5686' class='u'>paredit-point-at-sexp-end</a> ()
  (<a id='5687' tid='5688' class='u'>save-excursion</a>
    (<a id='5689' tid='5690' class='u'>backward-sexp</a>)
    (<a id='5691' tid='5692' class='u'>forward-sexp</a>)
    (<a id='5693' tid='5694' class='u'>point</a>)))

(<a id='5185' tid='5186' class='u'>defun</a> <a id='5187' tid='5188' class='u'>paredit-lose-if-not-in-sexp</a> (<a id='5189' tid='5190' class='u'>command</a>)
  (<a id='5191' tid='5192' class='u'>if</a> (<a id='5193' tid='5194' class='u'>or</a> (<a id='5195' tid='5196' class='u'>paredit-in-string-p</a>)
          (<a id='5197' tid='5198' class='u'>paredit-in-comment-p</a>)
          (<a id='5199' tid='5200' class='u'>paredit-in-char-p</a>))
      (<a id='5201' tid='5202' class='u'>error</a> <a id='5203' tid='5204' class='u'>&quot;Invalid context for command `%s&#39;.&quot;</a> <a id='5205' tid='5206' class='u'>command</a>)))

(<a id='2609' tid='2610' class='u'>defun</a> <a id='2611' tid='2612' class='u'>paredit-check-region</a> (<a id='2613' tid='2614' class='u'>start</a> <a id='2615' tid='2616' class='u'>end</a>)
  <span class='d'>(save-restriction
    (narrow-to-region start end)
    (if (fboundp &#39;check-parens)
        (check-parens)
        (save-excursion
          (goto-char (point-min))
          (while (not (eobp))
            (forward-sexp)))))</span>)

(<a id='5721' tid='5722' class='u'>defun</a> <a id='5723' tid='5724' class='u'>paredit-region-ok-p</a> (<a id='5725' tid='5726' class='u'>start</a> <a id='5727' tid='5728' class='u'>end</a>)
  <span class='d'>(paredit-handle-sexp-errors
      (progn
        (save-restriction
          (narrow-to-region start end)
          ;; Can&#39;t use `check-parens&#39; here -- it signals the wrong kind
          ;; of errors.
          (save-excursion
            (goto-char (point-min))
            (while (not (eobp))
              (forward-sexp))))
        t)
    nil)</span>)

<a id='7499' tid='7500' class='u'>;;;; Initialization
</a>
(<a id='7501' tid='7502' class='u'>paredit-define-keys</a>)
(<a id='7503' tid='7504' class='u'>paredit-annotate-mode-with-examples</a>)
(<a id='7505' tid='7506' class='u'>paredit-annotate-functions-with-examples</a>)

(<a id='7507' tid='7508' class='u'>provide</a> <a id='7509' tid='7510' class='u'>&#39;</a><a id='7511' tid='7512' class='u'>paredit</a>)

<a id='7513' tid='7514' class='u'>;;; Local Variables:
</a><a id='7515' tid='7516' class='u'>;;; outline-regexp: &quot;\n;;;;+&quot;
</a><a id='7517' tid='7518' class='u'>;;; End:
</a>
<a id='7519' tid='7520' class='u'>;;; paredit.el ends here
</a>
</pre>
</div>
<div id="right" class="src">
<pre>
<a id='rightstart' tid='leftstart'></a>
<a id='6752' tid='6751' class='u'>;;; paredit.el --- minor mode for editing parentheses  -*- Mode: Emacs-Lisp -*-
</a>
<span class='i'>;; Copyright (C) 2005--2011 Taylor R. Campbell
</span>
<a id='6754' tid='6753' class='u'>;; Author: Taylor R. Campbell
</a><span class='i'>;; Version: 23
</span><a id='6756' tid='6755' class='u'>;; Created: 2005-07-31
</a><a id='6758' tid='6757' class='u'>;; Keywords: lisp
</a>
<a id='6760' tid='6759' class='u'>;; Paredit is free software: you can redistribute it and/or modify it
</a><a id='6762' tid='6761' class='u'>;; under the terms of the GNU General Public License as published by
</a><a id='6764' tid='6763' class='u'>;; the Free Software Foundation, either version 3 of the License, or
</a><a id='6766' tid='6765' class='u'>;; (at your option) any later version.
</a><a id='6768' tid='6767' class='u'>;;
</a><a id='6770' tid='6769' class='u'>;; Paredit is distributed in the hope that it will be useful, but
</a><a id='6772' tid='6771' class='u'>;; WITHOUT ANY WARRANTY; without even the implied warranty of
</a><a id='6774' tid='6773' class='u'>;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
</a><a id='6776' tid='6775' class='u'>;; GNU General Public License for more details.
</a><a id='6778' tid='6777' class='u'>;;
</a><a id='6780' tid='6779' class='u'>;; You should have received a copy of the GNU General Public License
</a><a id='6782' tid='6781' class='u'>;; along with paredit.  If not, see &lt;http://www.gnu.org/licenses/&gt;.
</a>
<a id='6784' tid='6783' class='u'>;;; This file is permanently stored at
</a><span class='i'>;;;   &lt;http://mumble.net/~campbell/emacs/paredit-23.el&gt;.
</span><a id='6786' tid='6785' class='u'>;;;
</a><a id='6788' tid='6787' class='u'>;;; The currently released version of paredit is available at
</a><a id='6790' tid='6789' class='u'>;;;   &lt;http://mumble.net/~campbell/emacs/paredit.el&gt;.
</a><a id='6792' tid='6791' class='u'>;;;
</a><a id='6794' tid='6793' class='u'>;;; The latest beta version of paredit is available at
</a><a id='6796' tid='6795' class='u'>;;;   &lt;http://mumble.net/~campbell/emacs/paredit-beta.el&gt;.
</a><a id='6798' tid='6797' class='u'>;;;
</a><a id='6800' tid='6799' class='u'>;;; Release notes are available at
</a><a id='6802' tid='6801' class='u'>;;;   &lt;http://mumble.net/~campbell/emacs/paredit.release&gt;.
</a>
<a id='6804' tid='6803' class='u'>;;; Install paredit by placing `paredit.el&#39; in `/path/to/elisp&#39;, a
</a><a id='6806' tid='6805' class='u'>;;; directory of your choice, and adding to your .emacs file:
</a><a id='6808' tid='6807' class='u'>;;;
</a><a id='6810' tid='6809' class='u'>;;;   (add-to-list &#39;load-path &quot;/path/to/elisp&quot;)
</a><a id='6812' tid='6811' class='u'>;;;   (autoload &#39;enable-paredit-mode &quot;paredit&quot;
</a><a id='6814' tid='6813' class='u'>;;;     &quot;Turn on pseudo-structural editing of Lisp code.&quot;
</a><a id='6816' tid='6815' class='u'>;;;     t)
</a><a id='6818' tid='6817' class='u'>;;;
</a><span class='i'>;;; Start Paredit Mode on the fly with `M-x paredit-mode RET&#39;, or
</span><span class='i'>;;; always enable it in a major mode `M&#39; (e.g., `lisp&#39;) with:
</span><a id='6820' tid='6819' class='u'>;;;
</a><a id='6822' tid='6821' class='u'>;;;   (add-hook M-mode-hook &#39;enable-paredit-mode)
</a><a id='6824' tid='6823' class='u'>;;;
</a><a id='6826' tid='6825' class='u'>;;; Customize paredit using `eval-after-load&#39;:
</a><a id='6828' tid='6827' class='u'>;;;
</a><a id='6830' tid='6829' class='u'>;;;   (eval-after-load &#39;paredit
</a><span class='i'>;;;     &#39;(progn
</span><span class='i'>;;;        (define-key paredit-mode-map (kbd &quot;ESC M-A-C-s-)&quot;)
</span><span class='i'>;;;          &#39;paredit-dwim)))
</span><span class='i'>;;;
</span><span class='i'>;;; Send questions, bug reports, comments, feature suggestions, &c.,
</span><span class='i'>;;; via email to the author&#39;s surname at mumble.net.
</span><span class='i'>;;;
</span><span class='i'>;;; Paredit should run in GNU Emacs 21 or later and XEmacs 21.5.28 or
</span><span class='i'>;;; later.
</span><span class='i'>;;;
</span><span class='i'>;;; *** WARNING *** IMPORTANT *** DO NOT SUBMIT BUGS BEFORE READING ***
</span><span class='i'>;;;
</span><span class='i'>;;; If you plan to submit a bug report, where some sequence of keys in
</span><span class='i'>;;; Paredit Mode, or some sequence of paredit commands, doesn&#39;t do what
</span><span class='i'>;;; you wanted, then it is helpful to isolate an example in a very
</span><span class='i'>;;; small buffer, and it is **ABSOLUTELY**ESSENTIAL** that you supply,
</span><span class='i'>;;; along with the sequence of keys or commands,
</span><span class='i'>;;;
</span><span class='i'>;;;   (1) the version of Emacs,
</span><span class='i'>;;;   (2) the version of paredit.el[*], and
</span><span class='i'>;;;   (3) the **COMPLETE** state of the buffer used to reproduce the
</span><span class='i'>;;;       problem, including major mode, minor modes, local key
</span><span class='i'>;;;       bindings, entire contents of the buffer, leading line breaks
</span><span class='i'>;;;       or spaces, &c.
</span><span class='i'>;;;
</span><span class='i'>;;; It is often extremely difficult to reproduce problems, especially
</span><span class='i'>;;; with commands such as `paredit-kill&#39;.  If you do not supply **ALL**
</span><span class='i'>;;; of this information, then it is highly probable that I cannot
</span><span class='i'>;;; reproduce your problem no matter how hard I try.  So, please,
</span><span class='i'>;;; include all of the above information.
</span><span class='i'>;;;
</span><span class='i'>;;; [*] If you are using a beta version of paredit, be sure that you
</span><span class='i'>;;;     are using the *latest* edition of the beta version, available
</span><span class='i'>;;;     at &lt;http://mumble.net/~campbell/emacs/paredit-beta.el&gt;.  If you
</span><span class='i'>;;;     are not using a beta version, then upgrade either to that or to
</span><span class='i'>;;;     the latest release version; I cannot support older versions,
</span><span class='i'>;;;     and I can&#39;t fathom any reason why you might be using them.  So
</span><span class='i'>;;;     the answer to item (2) should be either `release&#39; or `beta&#39;.
</span>
<span class='i'>;;; The paredit minor mode, Paredit Mode, binds common character keys,
</span><span class='i'>;;; such as `(&#39;, `)&#39;, `&quot;&#39;, and `\&#39;, to commands that carefully insert
</span><span class='i'>;;; S-expression structures in the buffer:
</span><a id='6832' tid='6831' class='u'>;;;
</a><span class='i'>;;;   ( inserts `()&#39;, leaving the point in the middle;
</span><span class='i'>;;;   ) moves the point over the next closing delimiter;
</span><span class='i'>;;;   &quot; inserts `&quot;&quot;&#39; if outside a string, or inserts an escaped
</span><span class='i'>;;;      double-quote if in the middle of a string, or moves over the
</span><span class='i'>;;;      closing double-quote if at the end of a string; and
</span><span class='i'>;;;   \ prompts for the character to escape, to avoid inserting lone
</span><span class='i'>;;;      backslashes that may break structure.
</span><span class='i'>;;;
</span><span class='i'>;;; In comments, these keys insert themselves.  If necessary, you can
</span><span class='i'>;;; insert these characters literally outside comments by pressing
</span><span class='i'>;;; `C-q&#39; before these keys, in case a mistake has broken the
</span><span class='i'>;;; structure.
</span><span class='i'>;;;
</span><span class='i'>;;; These key bindings are designed so that when typing new code in
</span><span class='i'>;;; Paredit Mode, you can generally type exactly the same sequence of
</span><span class='i'>;;; keys you would have typed without Paredit Mode.
</span><span class='i'>;;;
</span><span class='i'>;;; Paredit Mode also binds common editing keys, such as `DEL&#39;, `C-d&#39;,
</span><span class='i'>;;; and `C-k&#39;, to commands that respect S-expression structures in the
</span><span class='i'>;;; buffer:
</span><span class='i'>;;;
</span><span class='i'>;;;   DEL deletes the previous character, unless it is a delimiter: DEL
</span><span class='i'>;;;        will move the point backward over a closing delimiter, and
</span><span class='i'>;;;        will delete a delimiter pair together if between an open and
</span><span class='i'>;;;        closing delimiter;
</span><span class='i'>;;;
</span><span class='i'>;;;   C-d deletes the next character in much the same manner; and
</span><span class='i'>;;;
</span><span class='i'>;;;   C-k kills all S-expressions that begin anywhere between the point
</span><span class='i'>;;;        and the end of the line or the closing delimiter of the
</span><span class='i'>;;;        enclosing list, whichever is first.
</span><span class='i'>;;;
</span><span class='i'>;;; If necessary, you can delete a character, kill a line, &c.,
</span><span class='i'>;;; irrespective of S-expression structure, by pressing `C-u&#39; before
</span><span class='i'>;;; these keys, in case a mistake has broken the structure.
</span><span class='i'>;;;
</span><span class='i'>;;; Finally, Paredit Mode binds some keys to complex S-expression
</span><span class='i'>;;; editing operations.  For example, `C-&lt;right&gt;&#39; makes the enclosing
</span><span class='i'>;;; list slurp up an S-expression to its right (here `|&#39; denotes the
</span><span class='i'>;;; point):
</span><span class='i'>;;;
</span><span class='i'>;;;   (foo (bar | baz) quux)  C-&lt;right&gt;  (foo (bar | baz quux))
</span><span class='i'>;;;
</span><span class='i'>;;; Some paredit commands automatically reindent code.  When they do,
</span><span class='i'>;;; they try to indent as locally as possible, to avoid interfering
</span><span class='i'>;;; with any indentation you might have manually written.  Only the
</span><span class='i'>;;; advanced S-expression manipulation commands automatically reindent,
</span><span class='i'>;;; and only the forms that they immediately operated upon (and their
</span><span class='i'>;;; subforms).
</span><span class='i'>;;;
</span><span class='i'>;;; This code is written for clarity, not efficiency.  It frequently
</span><span class='i'>;;; walks over S-expressions redundantly.  If you have problems with
</span><span class='i'>;;; the time it takes to execute some of the commands, let me know.
</span>
<span class='i'>;;; This assumes Unix-style LF line endings.
</span>
<span class='i'>(defconst paredit-version 23)</span>
(<a id='6834' tid='6833' class='u'>defconst</a> <a id='6836' tid='6835' class='u'>paredit-beta-p</a> <a id='6838' tid='6837' class='u'>nil</a>)

(<a id='6916' tid='6915' class='u'>eval-and-compile</a>

  (<a id='6898' tid='6897' class='u'>defun</a> <a id='6900' tid='6899' class='u'>paredit-xemacs-p</a> ()
    <a id='6902' tid='6901' class='u'>;; No idea where I got this definition from.  Edward O&#39;Connor
</a>    <a id='6904' tid='6903' class='u'>;; (hober in #emacs) suggested the current definition.
</a>    <a id='6906' tid='6905' class='u'>;;   (and (boundp &#39;running-xemacs)
</a>    <a id='6908' tid='6907' class='u'>;;        running-xemacs)
</a>    (<a id='6910' tid='6909' class='u'>featurep</a> <a id='6912' tid='6911' class='u'>&#39;</a><a id='6914' tid='6913' class='u'>xemacs</a>))

  (<a id='6840' tid='6839' class='u'>defun</a> <a id='6842' tid='6841' class='u'>paredit-gnu-emacs-p</a> ()
    <a id='6844' tid='6843' class='u'>;++ This could probably be improved.
</a>    (<a id='6846' tid='6845' class='u'>not</a> (<a id='6848' tid='6847' class='u'>paredit-xemacs-p</a>)))

  (<a id='6918' tid='6917' class='u'>defmacro</a> <a id='6920' tid='6919' class='u'>xcond</a> (<a id='6922' tid='6921' class='u'>&rest</a> <a id='6924' tid='6923' class='u'>clauses</a>)
    <a id='6926' tid='6925' class='u'>&quot;Exhaustive COND.
Signal an error if no clause matches.&quot;</a>
    <a id='6928' tid='6927' class='u'>`</a>(<a id='6930' tid='6929' class='u'>cond</a> <a id='6932' tid='6931' class='u'>,</a><a id='6934' tid='6933' class='u'>@clauses</a>
           (<a id='6936' tid='6935' class='u'>t</a> (<a id='6938' tid='6937' class='u'>error</a> <a id='6940' tid='6939' class='u'>&quot;XCOND lost.&quot;</a>))))

  (<a id='6942' tid='6941' class='u'>defalias</a> <a id='6944' tid='6943' class='u'>&#39;</a><a id='6946' tid='6945' class='u'>paredit-warn</a> (<a id='6948' tid='6947' class='u'>if</a> (<a id='6950' tid='6949' class='u'>fboundp</a> <a id='6952' tid='6951' class='u'>&#39;</a><a id='6954' tid='6953' class='u'>warn</a>) <a id='6956' tid='6955' class='u'>&#39;</a><a id='6958' tid='6957' class='u'>warn</a> <a id='6960' tid='6959' class='u'>&#39;</a><a id='6962' tid='6961' class='u'>message</a>))

  (<a id='6850' tid='6849' class='u'>defvar</a> <a id='6852' tid='6851' class='u'>paredit-sexp-error-type</a>
    (<a id='6854' tid='6853' class='u'>with-temp-buffer</a>
      (<a id='6856' tid='6855' class='u'>insert</a> <a id='6858' tid='6857' class='u'>&quot;(&quot;</a>)
      (<a id='6860' tid='6859' class='u'>condition-case</a> <a id='6862' tid='6861' class='u'>condition</a>
          (<a id='6864' tid='6863' class='u'>backward-sexp</a>)
        (<a id='6866' tid='6865' class='u'>error</a> (<a id='6868' tid='6867' class='u'>if</a> (<a id='6870' tid='6869' class='u'>eq</a> (<a id='6872' tid='6871' class='u'>car</a> <a id='6874' tid='6873' class='u'>condition</a>) <a id='6876' tid='6875' class='u'>&#39;</a><a id='6878' tid='6877' class='u'>error</a>)
                   (<a id='6880' tid='6879' class='u'>paredit-warn</a> <a id='6882' tid='6881' class='u'>&quot;%s%s%s%s%s&quot;</a>
                                 <a id='6884' tid='6883' class='u'>&quot;Paredit is unable to discriminate&quot;</a>
                                 <a id='6886' tid='6885' class='u'>&quot; S-expression parse errors from&quot;</a>
                                 <a id='6888' tid='6887' class='u'>&quot; other errors. &quot;</a>
                                 <a id='6890' tid='6889' class='u'>&quot; This may cause obscure problems. &quot;</a>
                                 <a id='6892' tid='6891' class='u'>&quot; Please upgrade Emacs.&quot;</a>))
               (<a id='6894' tid='6893' class='u'>car</a> <a id='6896' tid='6895' class='u'>condition</a>)))))

  (<a id='6964' tid='6963' class='u'>defmacro</a> <a id='6966' tid='6965' class='u'>paredit-handle-sexp-errors</a> (<a id='6968' tid='6967' class='u'>body</a> <a id='6970' tid='6969' class='u'>&rest</a> <a id='6972' tid='6971' class='u'>handler</a>)
    <a id='6974' tid='6973' class='u'>`</a>(<a id='6976' tid='6975' class='u'>condition-case</a> ()
         <a id='6978' tid='6977' class='u'>,</a><a id='6980' tid='6979' class='u'>body</a>
       (<a id='6982' tid='6981' class='u'>,</a><a id='6984' tid='6983' class='u'>paredit-sexp-error-type</a> <a id='6986' tid='6985' class='u'>,</a><a id='6988' tid='6987' class='u'>@handler</a>)))

  (<a id='6990' tid='6989' class='u'>put</a> <a id='6992' tid='6991' class='u'>&#39;</a><a id='6994' tid='6993' class='u'>paredit-handle-sexp-errors</a> <a id='6996' tid='6995' class='u'>&#39;</a><a id='6998' tid='6997' class='u'>lisp-indent-function</a> <a id='7000' tid='6999' class='u'>1</a>)

  (<a id='7002' tid='7001' class='u'>defmacro</a> <a id='7004' tid='7003' class='u'>paredit-ignore-sexp-errors</a> (<a id='7006' tid='7005' class='u'>&rest</a> <a id='7008' tid='7007' class='u'>body</a>)
    <a id='7010' tid='7009' class='u'>`</a>(<a id='7012' tid='7011' class='u'>paredit-handle-sexp-errors</a> (<a id='7014' tid='7013' class='u'>progn</a> <a id='7016' tid='7015' class='u'>,</a><a id='7018' tid='7017' class='u'>@body</a>)
       <a id='7020' tid='7019' class='u'>nil</a>))

  (<a id='7022' tid='7021' class='u'>put</a> <a id='7024' tid='7023' class='u'>&#39;</a><a id='7026' tid='7025' class='u'>paredit-ignore-sexp-errors</a> <a id='7028' tid='7027' class='u'>&#39;</a><a id='7030' tid='7029' class='u'>lisp-indent-function</a> <a id='7032' tid='7031' class='u'>0</a>)

  <a id='7034' tid='7033' class='u'>nil</a>)

<a id='7036' tid='7035' class='u'>;;;; Minor Mode Definition
</a>
(<a id='5302' tid='5301' class='u'>defvar</a> <a id='5304' tid='5303' class='u'>paredit-mode-map</a> (<a id='5306' tid='5305' class='u'>make-sparse-keymap</a>)
  <a id='5308' tid='5307' class='u'>&quot;Keymap for the paredit minor mode.&quot;</a>)

<span class='i'>(defvar paredit-override-check-parens-function
  (lambda (condition) condition nil)
  &quot;Function to tell whether unbalanced text should inhibit Paredit Mode.&quot;)</span>

<a id='7038' tid='7037' class='u'>;;;###autoload
</a>(<a id='5294' tid='5293' class='u'>define-minor-mode</a> <a id='5296' tid='5295' class='u'>paredit-mode</a>
  <span class='i'>&quot;Minor mode for pseudo-structurally editing Lisp code.
With a prefix argument, enable Paredit Mode even if there are
  unbalanced parentheses in the buffer.
Paredit behaves badly if parentheses are unbalanced, so exercise
  caution when forcing Paredit Mode to be enabled, and consider
  fixing unbalanced parentheses instead.
\\&lt;paredit-mode-map&gt;&quot;</span>
  <a id='5298' tid='5297' class='u'>:lighter</a> <a id='5300' tid='5299' class='u'>&quot; Paredit&quot;</a>
  <span class='i'>;; Setting `paredit-mode&#39; to false here aborts enabling Paredit Mode.
</span>  (<a id='718' tid='717' class='m'>if</a> (<a id='720' tid='719' class='m'>and</a> <a id='722' tid='721' class='m'>paredit-mode</a>
           (<a id='724' tid='723' class='m'>not</a> <a id='726' tid='725' class='m'>current-prefix-arg</a>))
      (<a id='728' tid='727' class='m'>condition-case</a> <a id='730' tid='729' class='m'>condition</a>
          (<a id='732' tid='731' class='m'>check-parens</a>)
        (<span class='i'>error</span>
         (<span class='i'>if</span> <span class='i'>(not (funcall paredit-override-check-parens-function condition))</span>
             (<span class='i'>progn</span> <span class='i'>(setq paredit-mode nil)</span>
                    (<a id='734' tid='733' class='m'>signal</a> (<a id='736' tid='735' class='m'>car</a> <a id='738' tid='737' class='m'>condition</a>) (<a id='740' tid='739' class='m'>cdr</a> <a id='742' tid='741' class='m'>condition</a>))))))))

<span class='i'>(defun paredit-override-check-parens-interactively (condition)
  (y-or-n-p (format &quot;Enable Paredit Mode despite condition %S? &quot; condition)))</span>

(<a id='1778' tid='1777' class='u'>defun</a> <a id='1780' tid='1779' class='u'>enable-paredit-mode</a> ()
  <a id='1782' tid='1781' class='u'>&quot;Turn on pseudo-structural editing of Lisp code.&quot;</a>
  (<a id='1784' tid='1783' class='u'>interactive</a>)
  (<a id='1786' tid='1785' class='u'>paredit-mode</a> <a id='1788' tid='1787' class='u'>+1</a>))

(<a id='1766' tid='1765' class='u'>defun</a> <a id='1768' tid='1767' class='u'>disable-paredit-mode</a> ()
  <a id='1770' tid='1769' class='u'>&quot;Turn off pseudo-structural editing of Lisp code.&quot;</a>
  (<a id='1772' tid='1771' class='u'>interactive</a>)
  (<a id='1774' tid='1773' class='u'>paredit-mode</a> <a id='1776' tid='1775' class='u'>-1</a>))

(<a id='2204' tid='2203' class='u'>defvar</a> <a id='2206' tid='2205' class='u'>paredit-backward-delete-key</a>
  (<a id='2208' tid='2207' class='u'>xcond</a> ((<a id='2210' tid='2209' class='u'>paredit-xemacs-p</a>)    <a id='2212' tid='2211' class='u'>&quot;BS&quot;</a>)
         ((<a id='2214' tid='2213' class='u'>paredit-gnu-emacs-p</a>) <a id='2216' tid='2215' class='u'>&quot;DEL&quot;</a>)))

(<a id='3330' tid='3329' class='u'>defvar</a> <a id='3332' tid='3331' class='u'>paredit-forward-delete-keys</a>
  (<a id='3334' tid='3333' class='u'>xcond</a> ((<a id='3336' tid='3335' class='u'>paredit-xemacs-p</a>)    <a id='3338' tid='3337' class='u'>&#39;</a>(<a id='3340' tid='3339' class='u'>&quot;DEL&quot;</a>))
         ((<a id='3342' tid='3341' class='u'>paredit-gnu-emacs-p</a>) <a id='3344' tid='3343' class='u'>&#39;</a>(<a id='3346' tid='3345' class='u'>&quot;&lt;delete&gt;&quot;</a> <a id='3348' tid='3347' class='u'>&quot;&lt;deletechar&gt;&quot;</a>))))

<a id='7040' tid='7039' class='u'>;;;; Paredit Keys
</a>
<a id='7042' tid='7041' class='u'>;;; Separating the definition and initialization of this variable
</a><a id='7044' tid='7043' class='u'>;;; simplifies the development of paredit, since re-evaluating DEFVAR
</a><a id='7046' tid='7045' class='u'>;;; forms doesn&#39;t actually do anything.
</a>
(<a id='2618' tid='2617' class='u'>defvar</a> <a id='2620' tid='2619' class='u'>paredit-commands</a> <a id='2622' tid='2621' class='u'>nil</a>
  <a id='2624' tid='2623' class='u'>&quot;List of paredit commands with their keys and examples.&quot;</a>)

<a id='7048' tid='7047' class='u'>;;; Each specifier is of the form:
</a><a id='7050' tid='7049' class='u'>;;;   (key[s] function (example-input example-output) ...)
</a><a id='7052' tid='7051' class='u'>;;; where key[s] is either a single string suitable for passing to KBD
</a><a id='7054' tid='7053' class='u'>;;; or a list of such strings.  Entries in this list may also just be
</a><a id='7056' tid='7055' class='u'>;;; strings, in which case they are headings for the next entries.
</a>
(<a id='744' tid='743' class='m'>progn</a> (<a id='746' tid='745' class='m'>setq</a> <a id='748' tid='747' class='m'>paredit-commands</a>
 <a id='750' tid='749' class='m'>`</a>(
   <span class='i'>&quot;Basic Insertion Commands&quot;</span>
   (<a id='752' tid='751' class='m'>&quot;(&quot;</a>         <a id='754' tid='753' class='m'>paredit-open-round</a>
                (<a id='756' tid='755' class='m'>&quot;(a b |c d)&quot;</a>
                 <a id='758' tid='757' class='m'>&quot;(a b (|) c d)&quot;</a>)
                (<a id='760' tid='759' class='m'>&quot;(foo \&quot;bar |baz\&quot; quux)&quot;</a>
                 <a id='762' tid='761' class='m'>&quot;(foo \&quot;bar (|baz\&quot; quux)&quot;</a>))
   (<a id='526' tid='525' class='m'>&quot;)&quot;</a>         <a id='528' tid='527' class='m'>paredit-close-round</a>
                (<a id='530' tid='529' class='m'>&quot;(a b |c   )&quot;</a> <a id='532' tid='531' class='m'>&quot;(a b c)|&quot;</a>)
                (<a id='534' tid='533' class='m'>&quot;; Hello,| world!&quot;</a>
                 <a id='536' tid='535' class='m'>&quot;; Hello,)| world!&quot;</a>))
   (<a id='460' tid='459' class='m'>&quot;M-)&quot;</a>       <a id='462' tid='461' class='m'>paredit-close-round-and-newline</a>
                (<a id='464' tid='463' class='m'>&quot;(defun f (x|  ))&quot;</a>
                 <a id='466' tid='465' class='m'>&quot;(defun f (x)\n  |)&quot;</a>)
                (<a id='468' tid='467' class='m'>&quot;; (Foo.|&quot;</a>
                 <a id='470' tid='469' class='m'>&quot;; (Foo.)|&quot;</a>))
   <span class='i'>(&quot;[&quot;         paredit-open-square
                (&quot;(a b |c d)&quot;
                 &quot;(a b [|] c d)&quot;)
                (&quot;(foo \&quot;bar |baz\&quot; quux)&quot;
                 &quot;(foo \&quot;bar [|baz\&quot; quux)&quot;))</span>
   (<a id='426' tid='425' class='m'>&quot;]&quot;</a>         <a id='428' tid='427' class='m'>paredit-close-square</a>
                (<a id='430' tid='429' class='m'>&quot;(define-key keymap [frob|  ] &#39;frobnicate)&quot;</a>
                 <a id='432' tid='431' class='m'>&quot;(define-key keymap [frob]| &#39;frobnicate)&quot;</a>)
                (<a id='434' tid='433' class='m'>&quot;; [Bar.|&quot;</a>
                 <a id='436' tid='435' class='m'>&quot;; [Bar.]|&quot;</a>))

   <span class='i'>(&quot;\&quot;&quot;        paredit-doublequote
                (&quot;(frob grovel |full lexical)&quot;
                 &quot;(frob grovel \&quot;|\&quot; full lexical)&quot;
                 &quot;(frob grovel \&quot;\&quot;| full lexical)&quot;)
                (&quot;(foo \&quot;bar |baz\&quot; quux)&quot;
                 &quot;(foo \&quot;bar \\\&quot;|baz\&quot; quux)&quot;)
                (&quot;(frob grovel)   ; full |lexical&quot;
                 &quot;(frob grovel)   ; full \&quot;|lexical&quot;))</span>
   (<a id='316' tid='315' class='m'>&quot;M-\&quot;&quot;</a>      <a id='318' tid='317' class='m'>paredit-meta-doublequote</a>
                (<a id='320' tid='319' class='m'>&quot;(foo \&quot;bar |baz\&quot; quux)&quot;</a>
                 <a id='322' tid='321' class='m'>&quot;(foo \&quot;bar baz\&quot;\n     |quux)&quot;</a>)
                (<a id='324' tid='323' class='m'>&quot;(foo |(bar #\\x \&quot;baz \\\\ quux\&quot;) zot)&quot;</a>
                 <a id='326' tid='325' class='m'>,</a>(<a id='328' tid='327' class='m'>concat</a> <a id='330' tid='329' class='m'>&quot;(foo \&quot;|(bar #\\\\x \\\&quot;baz \\\\&quot;</a>
                          <a id='332' tid='331' class='m'>&quot;\\\\ quux\\\&quot;)\&quot; zot)&quot;</a>)))
   <span class='i'>(&quot;\\&quot;        paredit-backslash
                (&quot;(string #|)\n  ; Character to escape: x&quot;
                 &quot;(string #\\x|)&quot;)
                (&quot;\&quot;foo|bar\&quot;\n  ; Character to escape: \&quot;&quot;
                 &quot;\&quot;foo\\\&quot;|bar\&quot;&quot;))</span>
   <span class='i'>(&quot;;&quot;         paredit-semicolon
                (&quot;|(frob grovel)&quot;
                 &quot;;|(frob grovel)&quot;)
                (&quot;(frob |grovel)&quot;
                 &quot;(frob ;|grovel\n )&quot;)
                (&quot;(frob |grovel (bloit\n               zargh))&quot;
                 &quot;(frob ;|grovel\n (bloit\n  zargh))&quot;)
                (&quot;(frob grovel)          |&quot;
                 &quot;(frob grovel)          ;|&quot;))</span>
   <span class='i'>(&quot;M-;&quot;       paredit-comment-dwim
                (&quot;(foo |bar)   ; baz&quot;
                 &quot;(foo bar)                               ; |baz&quot;)
                (&quot;(frob grovel)|&quot;
                 &quot;(frob grovel)                           ;|&quot;)
                (&quot;(zot (foo bar)\n|\n     (baz quux))&quot;
                 &quot;(zot (foo bar)\n     ;; |\n     (baz quux))&quot;)
                (&quot;(zot (foo bar) |(baz quux))&quot;
                 &quot;(zot (foo bar)\n     ;; |\n     (baz quux))&quot;)
                (&quot;|(defun hello-world ...)&quot;
                 &quot;;;; |\n(defun hello-world ...)&quot;))</span>

   <span class='i'>(&quot;C-j&quot;       paredit-newline
                (&quot;(let ((n (frobbotz))) |(display (+ n 1)\nport))&quot;
                 ,(concat &quot;(let ((n (frobbotz)))&quot;
                          &quot;\n  |(display (+ n 1)&quot;
                          &quot;\n           port))&quot;)))</span>

   <span class='i'>&quot;Deleting & Killing&quot;</span>
   ((<a id='226' tid='225' class='m'>&quot;C-d&quot;</a> <a id='228' tid='227' class='m'>,</a><a id='230' tid='229' class='m'>@paredit-forward-delete-keys</a>)
                <a id='232' tid='231' class='m'>paredit-forward-delete</a>
                (<a id='234' tid='233' class='m'>&quot;(quu|x \&quot;zot\&quot;)&quot;</a> <a id='236' tid='235' class='m'>&quot;(quu| \&quot;zot\&quot;)&quot;</a>)
                (<a id='238' tid='237' class='m'>&quot;(quux |\&quot;zot\&quot;)&quot;</a>
                 <a id='240' tid='239' class='m'>&quot;(quux \&quot;|zot\&quot;)&quot;</a>
                 <a id='242' tid='241' class='m'>&quot;(quux \&quot;|ot\&quot;)&quot;</a>)
                (<a id='244' tid='243' class='m'>&quot;(foo (|) bar)&quot;</a> <a id='246' tid='245' class='m'>&quot;(foo | bar)&quot;</a>)
                (<a id='248' tid='247' class='m'>&quot;|(foo bar)&quot;</a> <a id='250' tid='249' class='m'>&quot;(|foo bar)&quot;</a>))
   (<a id='174' tid='173' class='m'>,</a><a id='176' tid='175' class='m'>paredit-backward-delete-key</a>
                <a id='178' tid='177' class='m'>paredit-backward-delete</a>
                (<a id='180' tid='179' class='m'>&quot;(\&quot;zot\&quot; q|uux)&quot;</a> <a id='182' tid='181' class='m'>&quot;(\&quot;zot\&quot; |uux)&quot;</a>)
                (<a id='184' tid='183' class='m'>&quot;(\&quot;zot\&quot;| quux)&quot;</a>
                 <a id='186' tid='185' class='m'>&quot;(\&quot;zot|\&quot; quux)&quot;</a>
                 <a id='188' tid='187' class='m'>&quot;(\&quot;zo|\&quot; quux)&quot;</a>)
                (<a id='190' tid='189' class='m'>&quot;(foo (|) bar)&quot;</a> <a id='192' tid='191' class='m'>&quot;(foo | bar)&quot;</a>)
                (<a id='194' tid='193' class='m'>&quot;(foo bar)|&quot;</a> <a id='196' tid='195' class='m'>&quot;(foo bar|)&quot;</a>))
   (<a id='154' tid='153' class='m'>&quot;C-k&quot;</a>       <a id='156' tid='155' class='m'>paredit-kill</a>
                (<a id='158' tid='157' class='m'>&quot;(foo bar)|     ; Useless comment!&quot;</a>
                 <a id='160' tid='159' class='m'>&quot;(foo bar)|&quot;</a>)
                (<a id='162' tid='161' class='m'>&quot;(|foo bar)     ; Useful comment!&quot;</a>
                 <a id='164' tid='163' class='m'>&quot;(|)     ; Useful comment!&quot;</a>)
                (<a id='166' tid='165' class='m'>&quot;|(foo bar)     ; Useless line!&quot;</a>
                 <a id='168' tid='167' class='m'>&quot;|&quot;</a>)
                (<a id='170' tid='169' class='m'>&quot;(foo \&quot;|bar baz\&quot;\n     quux)&quot;</a>
                 <a id='172' tid='171' class='m'>&quot;(foo \&quot;|\&quot;\n     quux)&quot;</a>))
   (<a id='136' tid='135' class='m'>&quot;M-d&quot;</a>       <a id='138' tid='137' class='m'>paredit-forward-kill-word</a>
                (<a id='140' tid='139' class='m'>&quot;|(foo bar)    ; baz&quot;</a>
                 <a id='142' tid='141' class='m'>&quot;(| bar)    ; baz&quot;</a>
                 <a id='144' tid='143' class='m'>&quot;(|)    ; baz&quot;</a>
                 <a id='146' tid='145' class='m'>&quot;()    ;|&quot;</a>)
                (<a id='148' tid='147' class='m'>&quot;;;;| Frobnicate\n(defun frobnicate ...)&quot;</a>
                 <a id='150' tid='149' class='m'>&quot;;;;|\n(defun frobnicate ...)&quot;</a>
                 <a id='152' tid='151' class='m'>&quot;;;;\n(| frobnicate ...)&quot;</a>))
   (<a id='116' tid='115' class='m'>,</a>(<a id='118' tid='117' class='m'>concat</a> <a id='120' tid='119' class='m'>&quot;M-&quot;</a> <a id='122' tid='121' class='m'>paredit-backward-delete-key</a>)
                <a id='124' tid='123' class='m'>paredit-backward-kill-word</a>
                (<a id='126' tid='125' class='m'>&quot;(foo bar)    ; baz\n(quux)|&quot;</a>
                 <a id='128' tid='127' class='m'>&quot;(foo bar)    ; baz\n(|)&quot;</a>
                 <a id='130' tid='129' class='m'>&quot;(foo bar)    ; |\n()&quot;</a>
                 <a id='132' tid='131' class='m'>&quot;(foo |)    ; \n()&quot;</a>
                 <a id='134' tid='133' class='m'>&quot;(|)    ; \n()&quot;</a>))

   <span class='i'>&quot;Movement & Navigation&quot;</span>
   (<a id='104' tid='103' class='m'>&quot;C-M-f&quot;</a>     <a id='106' tid='105' class='m'>paredit-forward</a>
                (<a id='108' tid='107' class='m'>&quot;(foo |(bar baz) quux)&quot;</a>
                 <a id='110' tid='109' class='m'>&quot;(foo (bar baz)| quux)&quot;</a>)
                (<a id='112' tid='111' class='m'>&quot;(foo (bar)|)&quot;</a>
                 <a id='114' tid='113' class='m'>&quot;(foo (bar))|&quot;</a>))
   (<a id='92' tid='91' class='m'>&quot;C-M-b&quot;</a>     <a id='94' tid='93' class='m'>paredit-backward</a>
                (<a id='96' tid='95' class='m'>&quot;(foo (bar baz)| quux)&quot;</a>
                 <a id='98' tid='97' class='m'>&quot;(foo |(bar baz) quux)&quot;</a>)
                (<a id='100' tid='99' class='m'>&quot;(|(foo) bar)&quot;</a>
                 <a id='102' tid='101' class='m'>&quot;|((foo) bar)&quot;</a>))
   <span class='i'>(&quot;C-M-u&quot;     paredit-backward-up)</span>
   <span class='i'>(&quot;C-M-d&quot;     paredit-forward-down)</span>
   <span class='i'>(&quot;C-M-p&quot;     paredit-backward-down)</span>  <span class='i'>; Built-in, these are FORWARD-
</span>   <span class='i'>(&quot;C-M-n&quot;     paredit-forward-up)</span>     <span class='i'>; & BACKWARD-LIST, which have
</span>                                        <span class='i'>; no need given C-M-f & C-M-b.
</span>
   <span class='i'>&quot;Depth-Changing Commands&quot;</span>
   <span class='i'>(&quot;M-(&quot;       paredit-wrap-round
                (&quot;(foo |bar baz)&quot;
                 &quot;(foo (|bar) baz)&quot;))</span>
   <span class='i'>(&quot;M-s&quot;       paredit-splice-sexp
                (&quot;(foo (bar| baz) quux)&quot;
                 &quot;(foo bar| baz quux)&quot;))</span>
   <span class='i'>((&quot;M-&lt;up&gt;&quot; &quot;ESC &lt;up&gt;&quot;)
                paredit-splice-sexp-killing-backward
                (&quot;(foo (let ((x 5)) |(sqrt n)) bar)&quot;
                 &quot;(foo |(sqrt n) bar)&quot;))</span>
   <span class='i'>((&quot;M-&lt;down&gt;&quot; &quot;ESC &lt;down&gt;&quot;)
                paredit-splice-sexp-killing-forward
                (&quot;(a (b c| d e) f)&quot;
                 &quot;(a b c| f)&quot;))</span>
   (<a id='82' tid='81' class='m'>&quot;M-r&quot;</a>       <a id='84' tid='83' class='m'>paredit-raise-sexp</a>
                (<a id='86' tid='85' class='m'>&quot;(dynamic-wind in (lambda () |body) out)&quot;</a>
                 <a id='88' tid='87' class='m'>&quot;(dynamic-wind in |body out)&quot;</a>
                 <a id='90' tid='89' class='m'>&quot;|body&quot;</a>))
   <span class='i'>(&quot;M-?&quot;       paredit-convolute-sexp
                (&quot;(let ((x 5) (y 3)) (frob |(zwonk)) (wibblethwop))&quot;
                 &quot;(frob |(let ((x 5) (y 3)) (zwonk) (wibblethwop)))&quot;))</span>

   <span class='i'>&quot;Barfage & Slurpage&quot;</span>
   ((<a id='68' tid='67' class='m'>&quot;C-)&quot;</a> <a id='70' tid='69' class='m'>&quot;C-&lt;right&gt;&quot;</a>)
                <a id='72' tid='71' class='m'>paredit-forward-slurp-sexp</a>
                (<a id='74' tid='73' class='m'>&quot;(foo (bar |baz) quux zot)&quot;</a>
                 <a id='76' tid='75' class='m'>&quot;(foo (bar |baz quux) zot)&quot;</a>)
                (<a id='78' tid='77' class='m'>&quot;(a b ((c| d)) e f)&quot;</a>
                 <a id='80' tid='79' class='m'>&quot;(a b ((c| d) e) f)&quot;</a>))
   ((<a id='58' tid='57' class='m'>&quot;C-}&quot;</a> <a id='60' tid='59' class='m'>&quot;C-&lt;left&gt;&quot;</a>)
                <a id='62' tid='61' class='m'>paredit-forward-barf-sexp</a>
                (<a id='64' tid='63' class='m'>&quot;(foo (bar |baz quux) zot)&quot;</a>
                 <a id='66' tid='65' class='m'>&quot;(foo (bar |baz) quux zot)&quot;</a>))
   ((<a id='42' tid='41' class='m'>&quot;C-(&quot;</a> <a id='44' tid='43' class='m'>&quot;C-M-&lt;left&gt;&quot;</a> <a id='46' tid='45' class='m'>&quot;ESC C-&lt;left&gt;&quot;</a>)
                <a id='48' tid='47' class='m'>paredit-backward-slurp-sexp</a>
                (<a id='50' tid='49' class='m'>&quot;(foo bar (baz| quux) zot)&quot;</a>
                 <a id='52' tid='51' class='m'>&quot;(foo (bar baz| quux) zot)&quot;</a>)
                (<a id='54' tid='53' class='m'>&quot;(a b ((c| d)) e f)&quot;</a>
                 <a id='56' tid='55' class='m'>&quot;(a (b (c| d)) e f)&quot;</a>))
   ((<a id='30' tid='29' class='m'>&quot;C-{&quot;</a> <a id='32' tid='31' class='m'>&quot;C-M-&lt;right&gt;&quot;</a> <a id='34' tid='33' class='m'>&quot;ESC C-&lt;right&gt;&quot;</a>)
                <a id='36' tid='35' class='m'>paredit-backward-barf-sexp</a>
                (<a id='38' tid='37' class='m'>&quot;(foo (bar baz |quux) zot)&quot;</a>
                 <a id='40' tid='39' class='m'>&quot;(foo bar (baz |quux) zot)&quot;</a>))

   <span class='i'>&quot;Miscellaneous Commands&quot;</span>
   (<a id='18' tid='17' class='m'>&quot;M-S&quot;</a>       <a id='20' tid='19' class='m'>paredit-split-sexp</a>
                (<a id='22' tid='21' class='m'>&quot;(hello| world)&quot;</a>
                 <a id='24' tid='23' class='m'>&quot;(hello)| (world)&quot;</a>)
                (<a id='26' tid='25' class='m'>&quot;\&quot;Hello, |world!\&quot;&quot;</a>
                 <a id='28' tid='27' class='m'>&quot;\&quot;Hello, \&quot;| \&quot;world!\&quot;&quot;</a>))
   (<a id='2' tid='1' class='m'>&quot;M-J&quot;</a>       <a id='4' tid='3' class='m'>paredit-join-sexps</a>
                (<a id='6' tid='5' class='m'>&quot;(hello)| (world)&quot;</a>
                 <a id='8' tid='7' class='m'>&quot;(hello| world)&quot;</a>)
                (<a id='10' tid='9' class='m'>&quot;\&quot;Hello, \&quot;| \&quot;world!\&quot;&quot;</a>
                 <a id='12' tid='11' class='m'>&quot;\&quot;Hello, |world!\&quot;&quot;</a>)
                (<a id='14' tid='13' class='m'>&quot;hello-\n|  world&quot;</a>
                 <a id='16' tid='15' class='m'>&quot;hello-|world&quot;</a>))
   <span class='i'>(&quot;C-c C-M-l&quot; paredit-recenter-on-sexp)</span>
   <span class='i'>(&quot;M-q&quot;       paredit-reindent-defun)</span>
   ))
       <a id='764' tid='763' class='m'>nil</a>)                             <span class='i'>; end of PROGN
</span>
<span class='i'>;;;;; Command Examples
</span>
(<a id='7058' tid='7057' class='u'>eval-and-compile</a>
  (<a id='7060' tid='7059' class='u'>defmacro</a> <a id='7062' tid='7061' class='u'>paredit-do-commands</a> (<a id='7064' tid='7063' class='u'>vars</a> <a id='7066' tid='7065' class='u'>string-case</a> <a id='7068' tid='7067' class='u'>&rest</a> <a id='7070' tid='7069' class='u'>body</a>)
    (<a id='7072' tid='7071' class='u'>let</a> ((<a id='7074' tid='7073' class='u'>spec</a>     (<a id='7076' tid='7075' class='u'>nth</a> <a id='7078' tid='7077' class='u'>0</a> <a id='7080' tid='7079' class='u'>vars</a>))
          (<a id='7082' tid='7081' class='u'>keys</a>     (<a id='7084' tid='7083' class='u'>nth</a> <a id='7086' tid='7085' class='u'>1</a> <a id='7088' tid='7087' class='u'>vars</a>))
          (<a id='7090' tid='7089' class='u'>fn</a>       (<a id='7092' tid='7091' class='u'>nth</a> <a id='7094' tid='7093' class='u'>2</a> <a id='7096' tid='7095' class='u'>vars</a>))
          (<a id='7098' tid='7097' class='u'>examples</a> (<a id='7100' tid='7099' class='u'>nth</a> <a id='7102' tid='7101' class='u'>3</a> <a id='7104' tid='7103' class='u'>vars</a>)))
      <a id='7106' tid='7105' class='u'>`</a>(<a id='7108' tid='7107' class='u'>dolist</a> (<a id='7110' tid='7109' class='u'>,</a><a id='7112' tid='7111' class='u'>spec</a> <a id='7114' tid='7113' class='u'>paredit-commands</a>)
         (<a id='7116' tid='7115' class='u'>if</a> (<a id='7118' tid='7117' class='u'>stringp</a> <a id='7120' tid='7119' class='u'>,</a><a id='7122' tid='7121' class='u'>spec</a>)
             <a id='7124' tid='7123' class='u'>,</a><a id='7126' tid='7125' class='u'>string-case</a>
           (<a id='7128' tid='7127' class='u'>let</a> ((<a id='7130' tid='7129' class='u'>,</a><a id='7132' tid='7131' class='u'>keys</a> (<a id='7134' tid='7133' class='u'>let</a> ((<a id='7136' tid='7135' class='u'>k</a> (<a id='7138' tid='7137' class='u'>car</a> <a id='7140' tid='7139' class='u'>,</a><a id='7142' tid='7141' class='u'>spec</a>)))
                          (<a id='7144' tid='7143' class='u'>cond</a> ((<a id='7146' tid='7145' class='u'>stringp</a> <a id='7148' tid='7147' class='u'>k</a>) (<a id='7150' tid='7149' class='u'>list</a> <a id='7152' tid='7151' class='u'>k</a>))
                                ((<a id='7154' tid='7153' class='u'>listp</a> <a id='7156' tid='7155' class='u'>k</a>) <a id='7158' tid='7157' class='u'>k</a>)
                                (<a id='7160' tid='7159' class='u'>t</a> (<a id='7162' tid='7161' class='u'>error</a> <a id='7164' tid='7163' class='u'>&quot;Invalid paredit command %s.&quot;</a>
                                          <a id='7166' tid='7165' class='u'>,</a><a id='7168' tid='7167' class='u'>spec</a>)))))
                 (<a id='7170' tid='7169' class='u'>,</a><a id='7172' tid='7171' class='u'>fn</a> (<a id='7174' tid='7173' class='u'>cadr</a> <a id='7176' tid='7175' class='u'>,</a><a id='7178' tid='7177' class='u'>spec</a>))
                 (<a id='7180' tid='7179' class='u'>,</a><a id='7182' tid='7181' class='u'>examples</a> (<a id='7184' tid='7183' class='u'>cddr</a> <a id='7186' tid='7185' class='u'>,</a><a id='7188' tid='7187' class='u'>spec</a>)))
             <a id='7190' tid='7189' class='u'>,</a><a id='7192' tid='7191' class='u'>@body</a>)))))

  (<a id='7194' tid='7193' class='u'>put</a> <a id='7196' tid='7195' class='u'>&#39;</a><a id='7198' tid='7197' class='u'>paredit-do-commands</a> <a id='7200' tid='7199' class='u'>&#39;</a><a id='7202' tid='7201' class='u'>lisp-indent-function</a> <a id='7204' tid='7203' class='u'>2</a>))

(<a id='2958' tid='2957' class='u'>defun</a> <a id='2960' tid='2959' class='u'>paredit-define-keys</a> ()
  (<a id='2962' tid='2961' class='u'>paredit-do-commands</a> (<a id='2964' tid='2963' class='u'>spec</a> <a id='2966' tid='2965' class='u'>keys</a> <a id='2968' tid='2967' class='u'>fn</a> <a id='2970' tid='2969' class='u'>examples</a>)
      <a id='2972' tid='2971' class='u'>nil</a>       <a id='2974' tid='2973' class='u'>; string case
</a>    (<a id='2976' tid='2975' class='u'>dolist</a> (<a id='2978' tid='2977' class='u'>key</a> <a id='2980' tid='2979' class='u'>keys</a>)
      (<a id='2982' tid='2981' class='u'>define-key</a> <a id='2984' tid='2983' class='u'>paredit-mode-map</a> (<a id='2986' tid='2985' class='u'>read-kbd-macro</a> <a id='2988' tid='2987' class='u'>key</a>) <a id='2990' tid='2989' class='u'>fn</a>))))

(<a id='3910' tid='3909' class='u'>defun</a> <a id='3912' tid='3911' class='u'>paredit-function-documentation</a> (<a id='3914' tid='3913' class='u'>fn</a>)
  (<a id='3916' tid='3915' class='u'>let</a> ((<a id='3918' tid='3917' class='u'>original-doc</a> (<a id='3920' tid='3919' class='u'>get</a> <a id='3922' tid='3921' class='u'>fn</a> <a id='3924' tid='3923' class='u'>&#39;</a><a id='3926' tid='3925' class='u'>paredit-original-documentation</a>))
        (<a id='3928' tid='3927' class='u'>doc</a> (<a id='3930' tid='3929' class='u'>documentation</a> <a id='3932' tid='3931' class='u'>fn</a> <a id='3934' tid='3933' class='u'>&#39;</a><a id='3936' tid='3935' class='u'>function-documentation</a>)))
    (<a id='3938' tid='3937' class='u'>or</a> <a id='3940' tid='3939' class='u'>original-doc</a>
        (<a id='3942' tid='3941' class='u'>progn</a> (<a id='3944' tid='3943' class='u'>put</a> <a id='3946' tid='3945' class='u'>fn</a> <a id='3948' tid='3947' class='u'>&#39;</a><a id='3950' tid='3949' class='u'>paredit-original-documentation</a> <a id='3952' tid='3951' class='u'>doc</a>)
               <a id='3954' tid='3953' class='u'>doc</a>))))

(<a id='1896' tid='1895' class='u'>defun</a> <a id='1898' tid='1897' class='u'>paredit-annotate-mode-with-examples</a> ()
  (<a id='1900' tid='1899' class='u'>let</a> ((<a id='1902' tid='1901' class='u'>contents</a>
         (<a id='1904' tid='1903' class='u'>list</a> (<a id='1906' tid='1905' class='u'>paredit-function-documentation</a> <a id='1908' tid='1907' class='u'>&#39;</a><a id='1910' tid='1909' class='u'>paredit-mode</a>))))
    (<a id='1912' tid='1911' class='u'>paredit-do-commands</a> (<a id='1914' tid='1913' class='u'>spec</a> <a id='1916' tid='1915' class='u'>keys</a> <a id='1918' tid='1917' class='u'>fn</a> <a id='1920' tid='1919' class='u'>examples</a>)
        (<a id='1922' tid='1921' class='u'>push</a> (<a id='1924' tid='1923' class='u'>concat</a> <a id='1926' tid='1925' class='u'>&quot;\n\n&quot;</a> <a id='1928' tid='1927' class='u'>spec</a> <a id='1930' tid='1929' class='u'>&quot;\n&quot;</a>)
              <a id='1932' tid='1931' class='u'>contents</a>)
      (<a id='1934' tid='1933' class='u'>let</a> ((<a id='1936' tid='1935' class='u'>name</a> (<a id='1938' tid='1937' class='u'>symbol-name</a> <a id='1940' tid='1939' class='u'>fn</a>)))
        (<a id='1942' tid='1941' class='u'>if</a> (<a id='1944' tid='1943' class='u'>string-match</a> (<a id='1946' tid='1945' class='u'>symbol-name</a> <a id='1948' tid='1947' class='u'>&#39;</a><a id='1950' tid='1949' class='u'>paredit-</a>) <a id='1952' tid='1951' class='u'>name</a>)
            (<a id='1954' tid='1953' class='u'>push</a> (<a id='1956' tid='1955' class='u'>concat</a> <a id='1958' tid='1957' class='u'>&quot;\n\n\\[&quot;</a> <a id='1960' tid='1959' class='u'>name</a> <a id='1962' tid='1961' class='u'>&quot;]\t&quot;</a> <a id='1964' tid='1963' class='u'>name</a>
                          (<a id='1966' tid='1965' class='u'>if</a> <a id='1968' tid='1967' class='u'>examples</a>
                              (<a id='1970' tid='1969' class='u'>mapconcat</a> (<a id='1972' tid='1971' class='u'>lambda</a> (<a id='1974' tid='1973' class='u'>example</a>)
                                           (<a id='1976' tid='1975' class='u'>concat</a>
                                            <a id='1978' tid='1977' class='u'>&quot;\n&quot;</a>
                                            (<a id='1980' tid='1979' class='u'>mapconcat</a> <a id='1982' tid='1981' class='u'>&#39;</a><a id='1984' tid='1983' class='u'>identity</a>
                                                       <a id='1986' tid='1985' class='u'>example</a>
                                                       <a id='1988' tid='1987' class='u'>&quot;\n  ---&gt;\n&quot;</a>)
                                            <a id='1990' tid='1989' class='u'>&quot;\n&quot;</a>))
                                         <a id='1992' tid='1991' class='u'>examples</a>
                                         <a id='1994' tid='1993' class='u'>&quot;&quot;</a>)
                              <a id='1996' tid='1995' class='u'>&quot;\n  (no examples)\n&quot;</a>))
                  <a id='1998' tid='1997' class='u'>contents</a>))))
    (<a id='2000' tid='1999' class='u'>put</a> <a id='2002' tid='2001' class='u'>&#39;</a><a id='2004' tid='2003' class='u'>paredit-mode</a> <a id='2006' tid='2005' class='u'>&#39;</a><a id='2008' tid='2007' class='u'>function-documentation</a>
         (<a id='2010' tid='2009' class='u'>apply</a> <a id='2012' tid='2011' class='u'>&#39;</a><a id='2014' tid='2013' class='u'>concat</a> (<a id='2016' tid='2015' class='u'>reverse</a> <a id='2018' tid='2017' class='u'>contents</a>))))
  <a id='2020' tid='2019' class='u'>;; PUT returns the huge string we just constructed, which we don&#39;t
</a>  <a id='2022' tid='2021' class='u'>;; want it to return.
</a>  <a id='2024' tid='2023' class='u'>nil</a>)

(<a id='1830' tid='1829' class='u'>defun</a> <a id='1832' tid='1831' class='u'>paredit-annotate-functions-with-examples</a> ()
  (<a id='1834' tid='1833' class='u'>paredit-do-commands</a> (<a id='1836' tid='1835' class='u'>spec</a> <a id='1838' tid='1837' class='u'>keys</a> <a id='1840' tid='1839' class='u'>fn</a> <a id='1842' tid='1841' class='u'>examples</a>)
      <a id='1844' tid='1843' class='u'>nil</a>       <a id='1846' tid='1845' class='u'>; string case
</a>    (<a id='1848' tid='1847' class='u'>put</a> <a id='1850' tid='1849' class='u'>fn</a> <a id='1852' tid='1851' class='u'>&#39;</a><a id='1854' tid='1853' class='u'>function-documentation</a>
         (<a id='1856' tid='1855' class='u'>concat</a> (<a id='1858' tid='1857' class='u'>paredit-function-documentation</a> <a id='1860' tid='1859' class='u'>fn</a>)
                 <a id='1862' tid='1861' class='u'>&quot;\n\n\\&lt;paredit-mode-map&gt;\\[&quot;</a> (<a id='1864' tid='1863' class='u'>symbol-name</a> <a id='1866' tid='1865' class='u'>fn</a>) <a id='1868' tid='1867' class='u'>&quot;]\n&quot;</a>
                 (<a id='1870' tid='1869' class='u'>mapconcat</a> (<a id='1872' tid='1871' class='u'>lambda</a> (<a id='1874' tid='1873' class='u'>example</a>)
                              (<a id='1876' tid='1875' class='u'>concat</a> <a id='1878' tid='1877' class='u'>&quot;\n&quot;</a>
                                      (<a id='1880' tid='1879' class='u'>mapconcat</a> <a id='1882' tid='1881' class='u'>&#39;</a><a id='1884' tid='1883' class='u'>identity</a>
                                                 <a id='1886' tid='1885' class='u'>example</a>
                                                 <a id='1888' tid='1887' class='u'>&quot;\n  -&gt;\n&quot;</a>)
                                      <a id='1890' tid='1889' class='u'>&quot;\n&quot;</a>))
                            <a id='1892' tid='1891' class='u'>examples</a>
                            <a id='1894' tid='1893' class='u'>&quot;&quot;</a>)))))

<a id='7206' tid='7205' class='u'>;;;;; HTML Examples
</a>
(<a id='4262' tid='4261' class='u'>defun</a> <a id='4264' tid='4263' class='u'>paredit-insert-html-examples</a> ()
  <a id='4266' tid='4265' class='u'>&quot;Insert HTML for a paredit quick reference table.&quot;</a>
  (<a id='4268' tid='4267' class='u'>interactive</a>)
  (<a id='4270' tid='4269' class='u'>let</a> ((<a id='4272' tid='4271' class='u'>insert-lines</a>
         (<a id='4274' tid='4273' class='u'>lambda</a> (<a id='4276' tid='4275' class='u'>&rest</a> <a id='4278' tid='4277' class='u'>lines</a>)
           (<a id='4280' tid='4279' class='u'>mapc</a> (<a id='4282' tid='4281' class='u'>lambda</a> (<a id='4284' tid='4283' class='u'>line</a>) (<a id='4286' tid='4285' class='u'>insert</a> <a id='4288' tid='4287' class='u'>line</a>) (<a id='4290' tid='4289' class='u'>newline</a>))
                 <a id='4292' tid='4291' class='u'>lines</a>)))
        (<a id='4294' tid='4293' class='u'>html-keys</a>
         (<a id='4296' tid='4295' class='u'>lambda</a> (<a id='4298' tid='4297' class='u'>keys</a>)
           (<a id='4300' tid='4299' class='u'>mapconcat</a> <a id='4302' tid='4301' class='u'>&#39;</a><a id='4304' tid='4303' class='u'>paredit-html-quote</a> <a id='4306' tid='4305' class='u'>keys</a> <a id='4308' tid='4307' class='u'>&quot;, &quot;</a>)))
        (<a id='4310' tid='4309' class='u'>html-example</a>
         (<a id='4312' tid='4311' class='u'>lambda</a> (<a id='4314' tid='4313' class='u'>example</a>)
           (<a id='4316' tid='4315' class='u'>concat</a> <a id='4318' tid='4317' class='u'>&quot;&lt;table&gt;&lt;tr&gt;&lt;td&gt;&lt;pre&gt;&quot;</a>
                   (<a id='4320' tid='4319' class='u'>mapconcat</a> <a id='4322' tid='4321' class='u'>&#39;</a><a id='4324' tid='4323' class='u'>paredit-html-quote</a>
                              <a id='4326' tid='4325' class='u'>example</a>
                              (<a id='4328' tid='4327' class='u'>concat</a> <a id='4330' tid='4329' class='u'>&quot;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&quot;</a>
                                      <a id='4332' tid='4331' class='u'>&quot;&nbsp;&nbsp;&nbsp;&nbsp;---&gt;&quot;</a>
                                      <a id='4334' tid='4333' class='u'>&quot;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;pre&gt;&quot;</a>))
                   <a id='4336' tid='4335' class='u'>&quot;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&quot;</a>)))
        (<a id='4338' tid='4337' class='u'>firstp</a> <a id='4340' tid='4339' class='u'>t</a>))
    (<a id='4342' tid='4341' class='u'>paredit-do-commands</a> (<a id='4344' tid='4343' class='u'>spec</a> <a id='4346' tid='4345' class='u'>keys</a> <a id='4348' tid='4347' class='u'>fn</a> <a id='4350' tid='4349' class='u'>examples</a>)
        (<a id='4352' tid='4351' class='u'>progn</a> (<a id='4354' tid='4353' class='u'>if</a> (<a id='4356' tid='4355' class='u'>not</a> <a id='4358' tid='4357' class='u'>firstp</a>)
                   (<a id='4360' tid='4359' class='u'>insert</a> <a id='4362' tid='4361' class='u'>&quot;&lt;/table&gt;\n&quot;</a>)
                   (<a id='4364' tid='4363' class='u'>setq</a> <a id='4366' tid='4365' class='u'>firstp</a> <a id='4368' tid='4367' class='u'>nil</a>))
               (<a id='4370' tid='4369' class='u'>funcall</a> <a id='4372' tid='4371' class='u'>insert-lines</a>
                        (<a id='4374' tid='4373' class='u'>concat</a> <a id='4376' tid='4375' class='u'>&quot;&lt;h3&gt;&quot;</a> <a id='4378' tid='4377' class='u'>spec</a> <a id='4380' tid='4379' class='u'>&quot;&lt;/h3&gt;&quot;</a>)
                        <a id='4382' tid='4381' class='u'>&quot;&lt;table border=\&quot;1\&quot; cellpadding=\&quot;1\&quot;&gt;&quot;</a>
                        <a id='4384' tid='4383' class='u'>&quot;  &lt;tr&gt;&quot;</a>
                        <a id='4386' tid='4385' class='u'>&quot;    &lt;th&gt;Command&lt;/th&gt;&quot;</a>
                        <a id='4388' tid='4387' class='u'>&quot;    &lt;th&gt;Keys&lt;/th&gt;&quot;</a>
                        <a id='4390' tid='4389' class='u'>&quot;    &lt;th&gt;Examples&lt;/th&gt;&quot;</a>
                        <a id='4392' tid='4391' class='u'>&quot;  &lt;/tr&gt;&quot;</a>))
      (<a id='4394' tid='4393' class='u'>let</a> ((<a id='4396' tid='4395' class='u'>name</a> (<a id='4398' tid='4397' class='u'>symbol-name</a> <a id='4400' tid='4399' class='u'>fn</a>)))
        (<a id='4402' tid='4401' class='u'>if</a> (<a id='4404' tid='4403' class='u'>string-match</a> (<a id='4406' tid='4405' class='u'>symbol-name</a> <a id='4408' tid='4407' class='u'>&#39;</a><a id='4410' tid='4409' class='u'>paredit-</a>) <a id='4412' tid='4411' class='u'>name</a>)
            (<a id='4414' tid='4413' class='u'>funcall</a> <a id='4416' tid='4415' class='u'>insert-lines</a>
                     <a id='4418' tid='4417' class='u'>&quot;  &lt;tr&gt;&quot;</a>
                     (<a id='4420' tid='4419' class='u'>concat</a> <a id='4422' tid='4421' class='u'>&quot;    &lt;td&gt;&lt;tt&gt;&quot;</a> <a id='4424' tid='4423' class='u'>name</a> <a id='4426' tid='4425' class='u'>&quot;&lt;/tt&gt;&lt;/td&gt;&quot;</a>)
                     (<a id='4428' tid='4427' class='u'>concat</a> <a id='4430' tid='4429' class='u'>&quot;    &lt;td align=\&quot;center\&quot;&gt;&quot;</a>
                             (<a id='4432' tid='4431' class='u'>funcall</a> <a id='4434' tid='4433' class='u'>html-keys</a> <a id='4436' tid='4435' class='u'>keys</a>)
                             <a id='4438' tid='4437' class='u'>&quot;&lt;/td&gt;&quot;</a>)
                     (<a id='4440' tid='4439' class='u'>concat</a> <a id='4442' tid='4441' class='u'>&quot;    &lt;td&gt;&quot;</a>
                             (<a id='4444' tid='4443' class='u'>if</a> <a id='4446' tid='4445' class='u'>examples</a>
                                 (<a id='4448' tid='4447' class='u'>mapconcat</a> <a id='4450' tid='4449' class='u'>html-example</a> <a id='4452' tid='4451' class='u'>examples</a>
                                            <a id='4454' tid='4453' class='u'>&quot;&lt;hr&gt;&quot;</a>)
                                 <a id='4456' tid='4455' class='u'>&quot;(no examples)&quot;</a>)
                             <a id='4458' tid='4457' class='u'>&quot;&lt;/td&gt;&quot;</a>)
                     <a id='4460' tid='4459' class='u'>&quot;  &lt;/tr&gt;&quot;</a>)))))
  (<a id='4462' tid='4461' class='u'>insert</a> <a id='4464' tid='4463' class='u'>&quot;&lt;/table&gt;\n&quot;</a>))

(<a id='3998' tid='3997' class='u'>defun</a> <a id='4000' tid='3999' class='u'>paredit-html-quote</a> (<a id='4002' tid='4001' class='u'>string</a>)
  (<a id='4004' tid='4003' class='u'>with-temp-buffer</a>
    (<a id='4006' tid='4005' class='u'>dotimes</a> (<a id='4008' tid='4007' class='u'>i</a> (<a id='4010' tid='4009' class='u'>length</a> <a id='4012' tid='4011' class='u'>string</a>))
      (<a id='4014' tid='4013' class='u'>insert</a> (<a id='4016' tid='4015' class='u'>let</a> ((<a id='4018' tid='4017' class='u'>c</a> (<a id='4020' tid='4019' class='u'>elt</a> <a id='4022' tid='4021' class='u'>string</a> <a id='4024' tid='4023' class='u'>i</a>)))
                (<a id='4026' tid='4025' class='u'>cond</a> ((<a id='4028' tid='4027' class='u'>eq</a> <a id='4030' tid='4029' class='u'>c</a> <a id='4032' tid='4031' class='u'>?\&lt;</a>) <a id='4034' tid='4033' class='u'>&quot;&lt;&quot;</a>)
                      ((<a id='4036' tid='4035' class='u'>eq</a> <a id='4038' tid='4037' class='u'>c</a> <a id='4040' tid='4039' class='u'>?\&gt;</a>) <a id='4042' tid='4041' class='u'>&quot;&gt;&quot;</a>)
                      ((<a id='4044' tid='4043' class='u'>eq</a> <a id='4046' tid='4045' class='u'>c</a> <a id='4048' tid='4047' class='u'>?\&</a>) <a id='4050' tid='4049' class='u'>&quot;&amp;&quot;</a>)
                      ((<a id='4052' tid='4051' class='u'>eq</a> <a id='4054' tid='4053' class='u'>c</a> <a id='4056' tid='4055' class='u'>?\&#39;</a>) <a id='4058' tid='4057' class='u'>&quot;&apos;&quot;</a>)
                      ((<a id='4060' tid='4059' class='u'>eq</a> <a id='4062' tid='4061' class='u'>c</a> <a id='4064' tid='4063' class='u'>?\&quot;</a>) <a id='4066' tid='4065' class='u'>&quot;&quot;&quot;</a>)
                      (<a id='4068' tid='4067' class='u'>t</a> <a id='4070' tid='4069' class='u'>c</a>)))))
    (<a id='4072' tid='4071' class='u'>buffer-string</a>)))

<a id='7208' tid='7207' class='u'>;;;; Delimiter Insertion
</a>
(<a id='784' tid='783' class='m'>eval-and-compile</a>
  (<a id='766' tid='765' class='m'>defun</a> <a id='768' tid='767' class='m'>paredit-conc-name</a> (<a id='770' tid='769' class='m'>&rest</a> <a id='772' tid='771' class='m'>strings</a>)
    (<a id='774' tid='773' class='m'>intern</a> (<a id='776' tid='775' class='m'>apply</a> <a id='778' tid='777' class='m'>&#39;</a><a id='780' tid='779' class='m'>concat</a> <a id='782' tid='781' class='m'>strings</a>)))

  (<a id='786' tid='785' class='m'>defmacro</a> <a id='788' tid='787' class='m'>define-paredit-pair</a> (<a id='790' tid='789' class='m'>open</a> <a id='792' tid='791' class='m'>close</a> <a id='794' tid='793' class='m'>name</a>)
    <a id='796' tid='795' class='m'>`</a>(<a id='960' tid='959' class='m'>progn</a>
       (<a id='798' tid='797' class='m'>defun</a> <a id='800' tid='799' class='m'>,</a>(<a id='802' tid='801' class='m'>paredit-conc-name</a> <a id='804' tid='803' class='m'>&quot;paredit-open-&quot;</a> <a id='806' tid='805' class='m'>name</a>) (<a id='808' tid='807' class='m'>&optional</a> <a id='810' tid='809' class='m'>n</a>)
         <a id='812' tid='811' class='m'>,</a>(<a id='814' tid='813' class='m'>concat</a> <a id='816' tid='815' class='m'>&quot;Insert a balanced &quot;</a> <a id='818' tid='817' class='m'>name</a> <a id='820' tid='819' class='m'>&quot; pair.
With a prefix argument N, put the closing &quot;</a> <a id='822' tid='821' class='m'>name</a> <a id='824' tid='823' class='m'>&quot; after N
  S-expressions forward.
If the region is active, `transient-mark-mode&#39; is enabled, and the
  region&#39;s start and end fall in the same parenthesis depth, insert a
  &quot;</a> <a id='826' tid='825' class='m'>name</a> <a id='828' tid='827' class='m'>&quot; pair around the region.
If in a string or a comment, insert a single &quot;</a> <a id='830' tid='829' class='m'>name</a> <a id='832' tid='831' class='m'>&quot;.
If in a character literal, do nothing.  This prevents changing what was
  in the character literal to a meaningful delimiter unintentionally.&quot;</a>)
         (<a id='834' tid='833' class='m'>interactive</a> <a id='836' tid='835' class='m'>&quot;P&quot;</a>)
         (<a id='838' tid='837' class='m'>cond</a> ((<a id='840' tid='839' class='m'>or</a> (<a id='842' tid='841' class='m'>paredit-in-string-p</a>)
                    (<a id='844' tid='843' class='m'>paredit-in-comment-p</a>))
                (<a id='846' tid='845' class='m'>insert</a> <a id='848' tid='847' class='m'>,</a><a id='850' tid='849' class='m'>open</a>))
               (<span class='i'>(not (paredit-in-char-p))</span>
                (<a id='852' tid='851' class='m'>paredit-insert-pair</a> <a id='854' tid='853' class='m'>n</a> <a id='856' tid='855' class='m'>,</a><a id='858' tid='857' class='m'>open</a> <a id='860' tid='859' class='m'>,</a><a id='862' tid='861' class='m'>close</a> <a id='864' tid='863' class='m'>&#39;</a><a id='866' tid='865' class='m'>goto-char</a>)
                <span class='i'>(save-excursion (backward-up-list) (indent-sexp))</span>)))
       (<a id='868' tid='867' class='m'>defun</a> <a id='870' tid='869' class='m'>,</a>(<a id='872' tid='871' class='m'>paredit-conc-name</a> <a id='874' tid='873' class='m'>&quot;paredit-close-&quot;</a> <a id='876' tid='875' class='m'>name</a>) ()
         <a id='878' tid='877' class='m'>,</a>(<a id='880' tid='879' class='m'>concat</a> <a id='882' tid='881' class='m'>&quot;Move past one closing delimiter and reindent.
\(Agnostic to the specific closing delimiter.)
If in a string or comment, insert a single closing &quot;</a> <a id='884' tid='883' class='m'>name</a> <a id='886' tid='885' class='m'>&quot;.
If in a character literal, do nothing.  This prevents changing what was
  in the character literal to a meaningful delimiter unintentionally.&quot;</a>)
         (<a id='888' tid='887' class='m'>interactive</a>)
         (<a id='890' tid='889' class='m'>paredit-move-past-close</a> <a id='892' tid='891' class='m'>,</a><a id='894' tid='893' class='m'>close</a>))
       (<a id='896' tid='895' class='m'>defun</a> <a id='898' tid='897' class='m'>,</a>(<a id='900' tid='899' class='m'>paredit-conc-name</a> <a id='902' tid='901' class='m'>&quot;paredit-close-&quot;</a> <a id='904' tid='903' class='m'>name</a> <a id='906' tid='905' class='m'>&quot;-and-newline&quot;</a>) ()
         <a id='908' tid='907' class='m'>,</a>(<a id='910' tid='909' class='m'>concat</a> <a id='912' tid='911' class='m'>&quot;Move past one closing delimiter, add a newline,&quot;</a>
                  <a id='914' tid='913' class='m'>&quot; and reindent.
If there was a margin comment after the closing delimiter, preserve it
  on the same line.&quot;</a>)
         (<a id='916' tid='915' class='m'>interactive</a>)
         (<a id='918' tid='917' class='m'>paredit-move-past-close-and-newline</a> <a id='920' tid='919' class='m'>,</a><a id='922' tid='921' class='m'>close</a>))
       (<a id='924' tid='923' class='m'>defun</a> <a id='926' tid='925' class='m'>,</a>(<a id='928' tid='927' class='m'>paredit-conc-name</a> <a id='930' tid='929' class='m'>&quot;paredit-wrap-&quot;</a> <a id='932' tid='931' class='m'>name</a>)
           (<a id='934' tid='933' class='m'>&optional</a> <a id='936' tid='935' class='m'>argument</a>)
         <a id='938' tid='937' class='m'>,</a>(<a id='940' tid='939' class='m'>concat</a> <a id='942' tid='941' class='m'>&quot;Wrap the following S-expression.
See `paredit-wrap-sexp&#39; for more details.&quot;</a>)
         (<a id='944' tid='943' class='m'>interactive</a> <a id='946' tid='945' class='m'>&quot;P&quot;</a>)
         (<a id='948' tid='947' class='m'>paredit-wrap-sexp</a> <a id='950' tid='949' class='m'>argument</a> <a id='952' tid='951' class='m'>,</a><a id='954' tid='953' class='m'>open</a> <a id='956' tid='955' class='m'>,</a><a id='958' tid='957' class='m'>close</a>))
       (<a id='962' tid='961' class='m'>add-to-list</a> <a id='964' tid='963' class='m'>&#39;</a><a id='966' tid='965' class='m'>paredit-wrap-commands</a>
                    <a id='968' tid='967' class='m'>&#39;</a><a id='970' tid='969' class='m'>,</a>(<a id='972' tid='971' class='m'>paredit-conc-name</a> <a id='974' tid='973' class='m'>&quot;paredit-wrap-&quot;</a> <a id='976' tid='975' class='m'>name</a>)))))

(<a id='6538' tid='6537' class='u'>defvar</a> <a id='6540' tid='6539' class='u'>paredit-wrap-commands</a> <a id='6542' tid='6541' class='u'>&#39;</a>(<a id='6544' tid='6543' class='u'>paredit-wrap-sexp</a>)
  <a id='6546' tid='6545' class='u'>&quot;List of paredit commands that wrap S-expressions.
Used by `paredit-yank-pop&#39;; for internal paredit use only.&quot;</a>)

(<a id='7210' tid='7209' class='u'>define-paredit-pair</a> <a id='7212' tid='7211' class='u'>?\(</a> <a id='7214' tid='7213' class='u'>?\)</a> <a id='7216' tid='7215' class='u'>&quot;round&quot;</a>)
(<a id='7218' tid='7217' class='u'>define-paredit-pair</a> <a id='7220' tid='7219' class='u'>?\[</a> <a id='7222' tid='7221' class='u'>?\]</a> <a id='7224' tid='7223' class='u'>&quot;square&quot;</a>)
(<a id='7226' tid='7225' class='u'>define-paredit-pair</a> <a id='7228' tid='7227' class='u'>?\{</a> <a id='7230' tid='7229' class='u'>?\}</a> <a id='7232' tid='7231' class='u'>&quot;curly&quot;</a>)
(<a id='7234' tid='7233' class='u'>define-paredit-pair</a> <a id='7236' tid='7235' class='u'>?\&lt;</a> <a id='7238' tid='7237' class='u'>?\&gt;</a> <a id='7240' tid='7239' class='u'>&quot;angled&quot;</a>)

<a id='7242' tid='7241' class='u'>;;; Aliases for the old names.
</a>
(<a id='7244' tid='7243' class='u'>defalias</a> <a id='7246' tid='7245' class='u'>&#39;</a><a id='7248' tid='7247' class='u'>paredit-open-parenthesis</a> <a id='7250' tid='7249' class='u'>&#39;</a><a id='7252' tid='7251' class='u'>paredit-open-round</a>)
(<a id='7254' tid='7253' class='u'>defalias</a> <a id='7256' tid='7255' class='u'>&#39;</a><a id='7258' tid='7257' class='u'>paredit-close-parenthesis</a> <a id='7260' tid='7259' class='u'>&#39;</a><a id='7262' tid='7261' class='u'>paredit-close-round</a>)
(<a id='7264' tid='7263' class='u'>defalias</a> <a id='7266' tid='7265' class='u'>&#39;</a><a id='7268' tid='7267' class='u'>paredit-close-parenthesis-and-newline</a>
  <a id='7270' tid='7269' class='u'>&#39;</a><a id='7272' tid='7271' class='u'>paredit-close-round-and-newline</a>)

(<a id='7274' tid='7273' class='u'>defalias</a> <a id='7276' tid='7275' class='u'>&#39;</a><a id='7278' tid='7277' class='u'>paredit-open-bracket</a> <a id='7280' tid='7279' class='u'>&#39;</a><a id='7282' tid='7281' class='u'>paredit-open-square</a>)
(<a id='7284' tid='7283' class='u'>defalias</a> <a id='7286' tid='7285' class='u'>&#39;</a><a id='7288' tid='7287' class='u'>paredit-close-bracket</a> <a id='7290' tid='7289' class='u'>&#39;</a><a id='7292' tid='7291' class='u'>paredit-close-square</a>)
(<a id='7294' tid='7293' class='u'>defalias</a> <a id='7296' tid='7295' class='u'>&#39;</a><a id='7298' tid='7297' class='u'>paredit-close-bracket-and-newline</a>
  <a id='7300' tid='7299' class='u'>&#39;</a><a id='7302' tid='7301' class='u'>paredit-close-square-and-newline</a>)

(<a id='5310' tid='5309' class='u'>defun</a> <a id='5312' tid='5311' class='u'>paredit-move-past-close</a> (<a id='5314' tid='5313' class='u'>close</a>)
  <span class='i'>(paredit-move-past-close-and close
    (lambda ()
      (paredit-blink-paren-match nil)))</span>)

(<a id='5316' tid='5315' class='u'>defun</a> <a id='5318' tid='5317' class='u'>paredit-move-past-close-and-newline</a> (<a id='5320' tid='5319' class='u'>close</a>)
  (<span class='i'>paredit-move-past-close-and</span> <span class='i'>close</span>
    (<span class='i'>lambda</span> <span class='i'>()</span>
      (<a id='978' tid='977' class='m'>let</a> ((<a id='980' tid='979' class='m'>comment.point</a> (<a id='982' tid='981' class='m'>paredit-find-comment-on-line</a>)))
        (<a id='984' tid='983' class='m'>newline</a>)
        (<a id='986' tid='985' class='m'>if</a> <a id='988' tid='987' class='m'>comment.point</a>
            (<a id='990' tid='989' class='m'>save-excursion</a>
              (<a id='992' tid='991' class='m'>forward-line</a> <a id='994' tid='993' class='m'>-1</a>)
              (<a id='996' tid='995' class='m'>end-of-line</a>)
              (<a id='998' tid='997' class='m'>indent-to</a> (<a id='1000' tid='999' class='m'>cdr</a> <a id='1002' tid='1001' class='m'>comment.point</a>))
              (<a id='1004' tid='1003' class='m'>insert</a> (<a id='1006' tid='1005' class='m'>car</a> <a id='1008' tid='1007' class='m'>comment.point</a>)))))
      <span class='i'>(lisp-indent-line)</span>
      <span class='i'>(paredit-ignore-sexp-errors (indent-sexp))</span>
      <span class='i'>(paredit-blink-paren-match t)</span>)))

<span class='i'>(defun paredit-move-past-close-and (close if-moved)
  (if (or (paredit-in-string-p)
          (paredit-in-comment-p))
      (insert close)
    (if (paredit-in-char-p) (forward-char))
    (paredit-move-past-close-and-reindent close)
    (funcall if-moved)))</span>

(<a id='3106' tid='3105' class='u'>defun</a> <a id='3108' tid='3107' class='u'>paredit-find-comment-on-line</a> ()
  <a id='3110' tid='3109' class='u'>&quot;Find a margin comment on the current line.
Return nil if there is no such comment or if there is anything but
  whitespace until such a comment.
If such a comment exists, delete the comment (including all leading
  whitespace) and return a cons whose car is the comment as a string
  and whose cdr is the point of the comment&#39;s initial semicolon,
  relative to the start of the line.&quot;</a>
  (<a id='3112' tid='3111' class='u'>save-excursion</a>
    (<a id='3114' tid='3113' class='u'>paredit-skip-whitespace</a> <a id='3116' tid='3115' class='u'>t</a> (<a id='3118' tid='3117' class='u'>point-at-eol</a>))
    (<a id='3120' tid='3119' class='u'>and</a> (<a id='3122' tid='3121' class='u'>eq</a> <a id='3124' tid='3123' class='u'>?\;</a> (<a id='3126' tid='3125' class='u'>char-after</a>))
         (<a id='3128' tid='3127' class='u'>not</a> (<a id='3130' tid='3129' class='u'>eq</a> <a id='3132' tid='3131' class='u'>?\;</a> (<a id='3134' tid='3133' class='u'>char-after</a> (<a id='3136' tid='3135' class='u'>1+</a> (<a id='3138' tid='3137' class='u'>point</a>)))))
         (<a id='3140' tid='3139' class='u'>not</a> (<a id='3142' tid='3141' class='u'>or</a> (<a id='3144' tid='3143' class='u'>paredit-in-string-p</a>)
                  (<a id='3146' tid='3145' class='u'>paredit-in-char-p</a>)))
         (<a id='3148' tid='3147' class='u'>let*</a> ((<a id='3150' tid='3149' class='u'>start</a>                  <a id='3152' tid='3151' class='u'>;Move to before the semicolon.
</a>                 (<a id='3154' tid='3153' class='u'>progn</a> (<a id='3156' tid='3155' class='u'>backward-char</a>) (<a id='3158' tid='3157' class='u'>point</a>)))
                (<a id='3160' tid='3159' class='u'>comment</a>
                 (<a id='3162' tid='3161' class='u'>buffer-substring</a> <a id='3164' tid='3163' class='u'>start</a> (<a id='3166' tid='3165' class='u'>point-at-eol</a>))))
           (<a id='3168' tid='3167' class='u'>paredit-skip-whitespace</a> <a id='3170' tid='3169' class='u'>nil</a> (<a id='3172' tid='3171' class='u'>point-at-bol</a>))
           (<a id='3174' tid='3173' class='u'>delete-region</a> (<a id='3176' tid='3175' class='u'>point</a>) (<a id='3178' tid='3177' class='u'>point-at-eol</a>))
           (<a id='3180' tid='3179' class='u'>cons</a> <a id='3182' tid='3181' class='u'>comment</a> (<a id='3184' tid='3183' class='u'>-</a> <a id='3186' tid='3185' class='u'>start</a> (<a id='3188' tid='3187' class='u'>point-at-bol</a>)))))))

(<a id='4466' tid='4465' class='u'>defun</a> <a id='4468' tid='4467' class='u'>paredit-insert-pair</a> (<a id='4470' tid='4469' class='u'>n</a> <a id='4472' tid='4471' class='u'>open</a> <a id='4474' tid='4473' class='u'>close</a> <a id='4476' tid='4475' class='u'>forward</a>)
  (<a id='1010' tid='1009' class='m'>let*</a> ((<a id='1012' tid='1011' class='m'>regionp</a>
          (<a id='1014' tid='1013' class='m'>and</a> (<a id='1016' tid='1015' class='m'>paredit-region-active-p</a>)
               (<a id='1018' tid='1017' class='m'>paredit-region-safe-for-insert-p</a>)))
         (<a id='1020' tid='1019' class='m'>end</a>
          (<a id='1022' tid='1021' class='m'>and</a> <a id='1024' tid='1023' class='m'>regionp</a>
               (<a id='1026' tid='1025' class='m'>not</a> <a id='1028' tid='1027' class='m'>n</a>)
               (<a id='1030' tid='1029' class='m'>prog1</a> (<a id='1032' tid='1031' class='m'>region-end</a>) (<a id='1034' tid='1033' class='m'>goto-char</a> (<a id='1036' tid='1035' class='m'>region-beginning</a>))))))
    (<a id='1038' tid='1037' class='m'>let</a> ((<a id='1040' tid='1039' class='m'>spacep</a> (<a id='1042' tid='1041' class='m'>paredit-space-for-delimiter-p</a> <a id='1044' tid='1043' class='m'>nil</a> <a id='1046' tid='1045' class='m'>open</a>)))
      (<a id='1048' tid='1047' class='m'>if</a> <a id='1050' tid='1049' class='m'>spacep</a> (<a id='1052' tid='1051' class='m'>insert</a> <a id='1054' tid='1053' class='m'>&quot; &quot;</a>))
      (<a id='1056' tid='1055' class='m'>insert</a> <a id='1058' tid='1057' class='m'>open</a>)
      (<span class='i'>save-excursion</span>
        <span class='i'>;; Move past the desired region.
</span>        (<span class='i'>cond</span> <span class='i'>(n
               (funcall forward
                        (paredit-scan-sexps-hack (point)
                                                 (prefix-numeric-value n))))</span>
              (<a id='1060' tid='1059' class='m'>regionp</a>
               (<a id='1062' tid='1061' class='m'>funcall</a> <a id='1064' tid='1063' class='m'>forward</a> (<a id='1066' tid='1065' class='m'>+</a> <a id='1068' tid='1067' class='m'>end</a> (<a id='1070' tid='1069' class='m'>if</a> <a id='1072' tid='1071' class='m'>spacep</a> <a id='1074' tid='1073' class='m'>2</a> <a id='1076' tid='1075' class='m'>1</a>)))))
        <span class='i'>;; The string case can happen if we are inserting string
</span>        <span class='i'>;; delimiters.  The comment case may happen by moving to the
</span>        <span class='i'>;; end of a buffer that has a comment with no trailing newline.
</span>        <span class='i'>(if (and (not (paredit-in-string-p))
                 (paredit-in-comment-p))
            (newline))</span>
        <span class='i'>(insert close)</span>
        (<a id='538' tid='537' class='m'>if</a> (<a id='540' tid='539' class='m'>paredit-space-for-delimiter-p</a> <a id='542' tid='541' class='m'>t</a> <a id='544' tid='543' class='m'>close</a>)
            (<a id='546' tid='545' class='m'>insert</a> <a id='548' tid='547' class='m'>&quot; &quot;</a>))))))

<span class='i'>;++ This needs a better name...
</span>
<span class='i'>(defun paredit-scan-sexps-hack (point n)
  (save-excursion
    (goto-char point)
    (let ((direction (if (&lt; 0 n) +1 -1))
          (magnitude (abs n))
          (count 0))
      (catch &#39;exit
        (while (&lt; count magnitude)
          (let ((p
                 (paredit-handle-sexp-errors (scan-sexps (point) direction)
                   nil)))
            (if (not p) (throw &#39;exit nil))
            (goto-char p))
          (setq count (+ count 1)))))
    (point)))</span>

(<a id='5730' tid='5729' class='u'>defun</a> <a id='5732' tid='5731' class='u'>paredit-region-safe-for-insert-p</a> ()
  (<a id='5734' tid='5733' class='u'>save-excursion</a>
    (<a id='5736' tid='5735' class='u'>let</a> ((<a id='5738' tid='5737' class='u'>beginning</a> (<a id='5740' tid='5739' class='u'>region-beginning</a>))
          (<a id='5742' tid='5741' class='u'>end</a> (<a id='5744' tid='5743' class='u'>region-end</a>)))
      (<a id='5746' tid='5745' class='u'>goto-char</a> <a id='5748' tid='5747' class='u'>beginning</a>)
      (<a id='5750' tid='5749' class='u'>let*</a> ((<a id='5752' tid='5751' class='u'>beginning-state</a> (<a id='5754' tid='5753' class='u'>paredit-current-parse-state</a>))
             (<a id='5756' tid='5755' class='u'>end-state</a>
              (<a id='5758' tid='5757' class='u'>parse-partial-sexp</a> <a id='5760' tid='5759' class='u'>beginning</a> <a id='5762' tid='5761' class='u'>end</a> <a id='5764' tid='5763' class='u'>nil</a> <a id='5766' tid='5765' class='u'>nil</a> <a id='5768' tid='5767' class='u'>beginning-state</a>)))
        (<a id='5770' tid='5769' class='u'>and</a> (<a id='5772' tid='5771' class='u'>=</a>  (<a id='5774' tid='5773' class='u'>nth</a> <a id='5776' tid='5775' class='u'>0</a> <a id='5778' tid='5777' class='u'>beginning-state</a>)   <a id='5780' tid='5779' class='u'>; 0. depth in parens
</a>                 (<a id='5782' tid='5781' class='u'>nth</a> <a id='5784' tid='5783' class='u'>0</a> <a id='5786' tid='5785' class='u'>end-state</a>))
             (<a id='5788' tid='5787' class='u'>eq</a> (<a id='5790' tid='5789' class='u'>nth</a> <a id='5792' tid='5791' class='u'>3</a> <a id='5794' tid='5793' class='u'>beginning-state</a>)   <a id='5796' tid='5795' class='u'>; 3. non-nil if inside a
</a>                 (<a id='5798' tid='5797' class='u'>nth</a> <a id='5800' tid='5799' class='u'>3</a> <a id='5802' tid='5801' class='u'>end-state</a>))        <a id='5804' tid='5803' class='u'>;    string
</a>             (<a id='5806' tid='5805' class='u'>eq</a> (<a id='5808' tid='5807' class='u'>nth</a> <a id='5810' tid='5809' class='u'>4</a> <a id='5812' tid='5811' class='u'>beginning-state</a>)   <a id='5814' tid='5813' class='u'>; 4. comment status, yada
</a>                 (<a id='5816' tid='5815' class='u'>nth</a> <a id='5818' tid='5817' class='u'>4</a> <a id='5820' tid='5819' class='u'>end-state</a>))
             (<a id='5822' tid='5821' class='u'>eq</a> (<a id='5824' tid='5823' class='u'>nth</a> <a id='5826' tid='5825' class='u'>5</a> <a id='5828' tid='5827' class='u'>beginning-state</a>)   <a id='5830' tid='5829' class='u'>; 5. t if following char
</a>                 (<a id='5832' tid='5831' class='u'>nth</a> <a id='5834' tid='5833' class='u'>5</a> <a id='5836' tid='5835' class='u'>end-state</a>)))))))   <span class='i'>;    quote
</span>
(<a id='6142' tid='6141' class='u'>defvar</a> <a id='6144' tid='6143' class='u'>paredit-space-for-delimiter-predicates</a> <a id='6146' tid='6145' class='u'>nil</a>
  <a id='6148' tid='6147' class='u'>&quot;List of predicates for whether to put space by delimiter at point.
Each predicate is a function that is is applied to two arguments, ENDP
  and DELIMITER, and that returns a boolean saying whether to put a
  space next to the delimiter -- before the delimiter if ENDP is false,
  after the delimiter if ENDP is true.
If any predicate returns false, no space is inserted: every predicate
  has veto power.
Each predicate may assume that the point is not at the beginning of the
  buffer, if ENDP is false, or at the end of the buffer, if ENDP is
  true; and that the point is not preceded, if ENDP is false, or
  followed, if ENDP is true, by a word or symbol constituent, a quote,
  or the delimiter matching DELIMITER.
Each predicate should examine only text before the point, if ENDP is
  false, or only text after the point, if ENDP is true.&quot;</a>)

(<a id='6028' tid='6027' class='u'>defun</a> <a id='6030' tid='6029' class='u'>paredit-space-for-delimiter-p</a> (<a id='6032' tid='6031' class='u'>endp</a> <a id='6034' tid='6033' class='u'>delimiter</a>)
  <a id='6036' tid='6035' class='u'>;; If at the buffer limit, don&#39;t insert a space.  If there is a word,
</a>  <a id='6038' tid='6037' class='u'>;; symbol, other quote, or non-matching parenthesis delimiter (i.e. a
</a>  <a id='6040' tid='6039' class='u'>;; close when want an open the string or an open when we want to
</a>  <a id='6042' tid='6041' class='u'>;; close the string), do insert a space.
</a>  (<a id='6044' tid='6043' class='u'>and</a> (<a id='6046' tid='6045' class='u'>not</a> (<a id='6048' tid='6047' class='u'>if</a> <a id='6050' tid='6049' class='u'>endp</a> (<a id='6052' tid='6051' class='u'>eobp</a>) (<a id='6054' tid='6053' class='u'>bobp</a>)))
       (<a id='6056' tid='6055' class='u'>memq</a> (<a id='6058' tid='6057' class='u'>char-syntax</a> (<a id='6060' tid='6059' class='u'>if</a> <a id='6062' tid='6061' class='u'>endp</a> (<a id='6064' tid='6063' class='u'>char-after</a>) (<a id='6066' tid='6065' class='u'>char-before</a>)))
             (<a id='6068' tid='6067' class='u'>list</a> <a id='6070' tid='6069' class='u'>?w</a> <a id='6072' tid='6071' class='u'>?_</a> <a id='6074' tid='6073' class='u'>?\&quot;</a>
                   (<a id='6076' tid='6075' class='u'>let</a> ((<a id='6078' tid='6077' class='u'>matching</a> (<a id='6080' tid='6079' class='u'>matching-paren</a> <a id='6082' tid='6081' class='u'>delimiter</a>)))
                     (<a id='6084' tid='6083' class='u'>and</a> <a id='6086' tid='6085' class='u'>matching</a> (<a id='6088' tid='6087' class='u'>char-syntax</a> <a id='6090' tid='6089' class='u'>matching</a>)))
                   (<a id='6092' tid='6091' class='u'>and</a> (<a id='6094' tid='6093' class='u'>not</a> <a id='6096' tid='6095' class='u'>endp</a>)
                        (<a id='6098' tid='6097' class='u'>eq</a> <a id='6100' tid='6099' class='u'>?\&quot;</a> (<a id='6102' tid='6101' class='u'>char-syntax</a> <a id='6104' tid='6103' class='u'>delimiter</a>))
                        <a id='6106' tid='6105' class='u'>?\)</a> )))
       (<a id='6108' tid='6107' class='u'>catch</a> <a id='6110' tid='6109' class='u'>&#39;</a><a id='6112' tid='6111' class='u'>exit</a>
         (<a id='6114' tid='6113' class='u'>dolist</a> (<a id='6116' tid='6115' class='u'>predicate</a> <a id='6118' tid='6117' class='u'>paredit-space-for-delimiter-predicates</a>)
           (<a id='6120' tid='6119' class='u'>if</a> (<a id='6122' tid='6121' class='u'>not</a> (<a id='6124' tid='6123' class='u'>funcall</a> <a id='6126' tid='6125' class='u'>predicate</a> <a id='6128' tid='6127' class='u'>endp</a> <a id='6130' tid='6129' class='u'>delimiter</a>))
               (<a id='6132' tid='6131' class='u'>throw</a> <a id='6134' tid='6133' class='u'>&#39;</a><a id='6136' tid='6135' class='u'>exit</a> <a id='6138' tid='6137' class='u'>nil</a>)))
         <a id='6140' tid='6139' class='u'>t</a>)))

(<a id='5322' tid='5321' class='u'>defun</a> <a id='5324' tid='5323' class='u'>paredit-move-past-close-and-reindent</a> (<a id='5326' tid='5325' class='u'>close</a>)
  (<a id='5328' tid='5327' class='u'>let</a> ((<a id='5330' tid='5329' class='u'>open</a> (<a id='5332' tid='5331' class='u'>paredit-missing-close</a>)))
    (<a id='5334' tid='5333' class='u'>if</a> <a id='5336' tid='5335' class='u'>open</a>
        (<a id='5338' tid='5337' class='u'>if</a> (<a id='5340' tid='5339' class='u'>eq</a> <a id='5342' tid='5341' class='u'>close</a> (<a id='5344' tid='5343' class='u'>matching-paren</a> <a id='5346' tid='5345' class='u'>open</a>))
            (<a id='5348' tid='5347' class='u'>save-excursion</a>
              (<a id='5350' tid='5349' class='u'>message</a> <a id='5352' tid='5351' class='u'>&quot;Missing closing delimiter: %c&quot;</a> <a id='5354' tid='5353' class='u'>close</a>)
              (<a id='5356' tid='5355' class='u'>insert</a> <a id='5358' tid='5357' class='u'>close</a>))
            (<a id='5360' tid='5359' class='u'>error</a> <a id='5362' tid='5361' class='u'>&quot;Mismatched missing closing delimiter: %c ... %c&quot;</a>
                   <a id='5364' tid='5363' class='u'>open</a> <a id='5366' tid='5365' class='u'>close</a>))))
  (<a id='5368' tid='5367' class='u'>up-list</a>)
  (<a id='5370' tid='5369' class='u'>if</a> (<a id='5372' tid='5371' class='u'>catch</a> <a id='5374' tid='5373' class='u'>&#39;</a><a id='5376' tid='5375' class='u'>return</a>                    <a id='5378' tid='5377' class='u'>; This CATCH returns T if it
</a>        (<a id='5380' tid='5379' class='u'>while</a> <a id='5382' tid='5381' class='u'>t</a>                        <a id='5384' tid='5383' class='u'>; should delete leading spaces
</a>          (<a id='5386' tid='5385' class='u'>save-excursion</a>               <a id='5388' tid='5387' class='u'>; and NIL if not.
</a>            (<a id='5390' tid='5389' class='u'>let</a> ((<a id='5392' tid='5391' class='u'>before-paren</a> (<a id='5394' tid='5393' class='u'>1-</a> (<a id='5396' tid='5395' class='u'>point</a>))))
              (<a id='5398' tid='5397' class='u'>back-to-indentation</a>)
              (<a id='5400' tid='5399' class='u'>cond</a> ((<a id='5402' tid='5401' class='u'>not</a> (<a id='5404' tid='5403' class='u'>eq</a> (<a id='5406' tid='5405' class='u'>point</a>) <a id='5408' tid='5407' class='u'>before-paren</a>))
                     <a id='5410' tid='5409' class='u'>;; Can&#39;t call PAREDIT-DELETE-LEADING-WHITESPACE
</a>                     <a id='5412' tid='5411' class='u'>;; here -- we must return from SAVE-EXCURSION
</a>                     <a id='5414' tid='5413' class='u'>;; first.
</a>                     (<a id='5416' tid='5415' class='u'>throw</a> <a id='5418' tid='5417' class='u'>&#39;</a><a id='5420' tid='5419' class='u'>return</a> <a id='5422' tid='5421' class='u'>t</a>))
                    ((<a id='5424' tid='5423' class='u'>save-excursion</a> (<a id='5426' tid='5425' class='u'>forward-line</a> <a id='5428' tid='5427' class='u'>-1</a>)
                                     (<a id='5430' tid='5429' class='u'>end-of-line</a>)
                                     (<a id='5432' tid='5431' class='u'>paredit-in-comment-p</a>))
                     <a id='5434' tid='5433' class='u'>;; Moving the closing delimiter any further
</a>                     <a id='5436' tid='5435' class='u'>;; would put it into a comment, so we just
</a>                     <a id='5438' tid='5437' class='u'>;; indent the closing delimiter where it is and
</a>                     <a id='5440' tid='5439' class='u'>;; abort the loop, telling its continuation that
</a>                     <a id='5442' tid='5441' class='u'>;; no leading whitespace should be deleted.
</a>                     (<a id='5444' tid='5443' class='u'>lisp-indent-line</a>)
                     (<a id='5446' tid='5445' class='u'>throw</a> <a id='5448' tid='5447' class='u'>&#39;</a><a id='5450' tid='5449' class='u'>return</a> <a id='5452' tid='5451' class='u'>nil</a>))
                    (<a id='5454' tid='5453' class='u'>t</a> (<a id='5456' tid='5455' class='u'>delete-indentation</a>)))))))
      (<a id='5458' tid='5457' class='u'>paredit-delete-leading-whitespace</a>)))

(<a id='5264' tid='5263' class='u'>defun</a> <a id='5266' tid='5265' class='u'>paredit-missing-close</a> ()
  (<a id='5268' tid='5267' class='u'>save-excursion</a>
    (<a id='5270' tid='5269' class='u'>paredit-handle-sexp-errors</a> (<a id='5272' tid='5271' class='u'>backward-up-list</a>)
      (<a id='5274' tid='5273' class='u'>error</a> <a id='5276' tid='5275' class='u'>&quot;Not inside a list.&quot;</a>))
    (<a id='5278' tid='5277' class='u'>let</a> ((<a id='5280' tid='5279' class='u'>open</a> (<a id='5282' tid='5281' class='u'>char-after</a>)))
      (<a id='5284' tid='5283' class='u'>paredit-handle-sexp-errors</a> (<a id='5286' tid='5285' class='u'>progn</a> (<a id='5288' tid='5287' class='u'>forward-sexp</a>) <a id='5290' tid='5289' class='u'>nil</a>)
        <a id='5292' tid='5291' class='u'>open</a>))))

(<a id='2992' tid='2991' class='u'>defun</a> <a id='2994' tid='2993' class='u'>paredit-delete-leading-whitespace</a> ()
  <a id='2996' tid='2995' class='u'>;; This assumes that we&#39;re on the closing delimiter already.
</a>  (<a id='2998' tid='2997' class='u'>save-excursion</a>
    (<a id='3000' tid='2999' class='u'>backward-char</a>)
    (<a id='3002' tid='3001' class='u'>while</a> (<a id='3004' tid='3003' class='u'>let</a> ((<a id='3006' tid='3005' class='u'>syn</a> (<a id='3008' tid='3007' class='u'>char-syntax</a> (<a id='3010' tid='3009' class='u'>char-before</a>))))
             (<a id='3012' tid='3011' class='u'>and</a> (<a id='3014' tid='3013' class='u'>or</a> (<a id='3016' tid='3015' class='u'>eq</a> <a id='3018' tid='3017' class='u'>syn</a> <a id='3020' tid='3019' class='u'>?\ </a>) (<a id='3022' tid='3021' class='u'>eq</a> <a id='3024' tid='3023' class='u'>syn</a> <a id='3026' tid='3025' class='u'>?-</a>))     <a id='3028' tid='3027' class='u'>; whitespace syntax
</a>                  <a id='3030' tid='3029' class='u'>;; The above line is a perfect example of why the
</a>                  <a id='3032' tid='3031' class='u'>;; following test is necessary.
</a>                  (<a id='3034' tid='3033' class='u'>not</a> (<a id='3036' tid='3035' class='u'>paredit-in-char-p</a> (<a id='3038' tid='3037' class='u'>1-</a> (<a id='3040' tid='3039' class='u'>point</a>))))))
      (<a id='3042' tid='3041' class='u'>backward-delete-char</a> <a id='3044' tid='3043' class='u'>1</a>))))

(<a id='2570' tid='2569' class='u'>defun</a> <a id='2572' tid='2571' class='u'>paredit-blink-paren-match</a> (<a id='2574' tid='2573' class='u'>another-line-p</a>)
  (<a id='2576' tid='2575' class='u'>if</a> (<a id='2578' tid='2577' class='u'>and</a> <a id='2580' tid='2579' class='u'>blink-matching-paren</a>
           (<a id='2582' tid='2581' class='u'>or</a> (<a id='2584' tid='2583' class='u'>not</a> <a id='2586' tid='2585' class='u'>show-paren-mode</a>) <a id='2588' tid='2587' class='u'>another-line-p</a>))
      (<a id='2590' tid='2589' class='u'>paredit-ignore-sexp-errors</a>
        (<a id='2592' tid='2591' class='u'>save-excursion</a>
          (<a id='2594' tid='2593' class='u'>backward-sexp</a>)
          (<a id='2596' tid='2595' class='u'>forward-sexp</a>)
          <a id='2598' tid='2597' class='u'>;; SHOW-PAREN-MODE inhibits any blinking, so we disable it
</a>          <a id='2600' tid='2599' class='u'>;; locally here.
</a>          (<a id='2602' tid='2601' class='u'>let</a> ((<a id='2604' tid='2603' class='u'>show-paren-mode</a> <a id='2606' tid='2605' class='u'>nil</a>))
            (<a id='2608' tid='2607' class='u'>blink-matching-open</a>))))))

(<a id='3046' tid='3045' class='u'>defun</a> <a id='3048' tid='3047' class='u'>paredit-doublequote</a> (<a id='3050' tid='3049' class='u'>&optional</a> <a id='3052' tid='3051' class='u'>n</a>)
  <a id='3054' tid='3053' class='u'>&quot;Insert a pair of double-quotes.
With a prefix argument N, wrap the following N S-expressions in
  double-quotes, escaping intermediate characters if necessary.
If the region is active, `transient-mark-mode&#39; is enabled, and the
  region&#39;s start and end fall in the same parenthesis depth, insert a
  pair of double-quotes around the region, again escaping intermediate
  characters if necessary.
Inside a comment, insert a literal double-quote.
At the end of a string, move past the closing double-quote.
In the middle of a string, insert a backslash-escaped double-quote.
If in a character literal, do nothing.  This prevents accidentally
  changing a what was in the character literal to become a meaningful
  delimiter unintentionally.&quot;</a>
  (<a id='3056' tid='3055' class='u'>interactive</a> <a id='3058' tid='3057' class='u'>&quot;P&quot;</a>)
  (<a id='3060' tid='3059' class='u'>cond</a> ((<a id='3062' tid='3061' class='u'>paredit-in-string-p</a>)
         (<a id='3064' tid='3063' class='u'>if</a> (<a id='3066' tid='3065' class='u'>eq</a> (<a id='3068' tid='3067' class='u'>cdr</a> (<a id='3070' tid='3069' class='u'>paredit-string-start+end-points</a>))
                 (<a id='3072' tid='3071' class='u'>point</a>))
             (<a id='3074' tid='3073' class='u'>forward-char</a>)             <a id='3076' tid='3075' class='u'>; We&#39;re on the closing quote.
</a>             (<a id='3078' tid='3077' class='u'>insert</a> <a id='3080' tid='3079' class='u'>?\\</a> <a id='3082' tid='3081' class='u'>?\&quot;</a> )))
        ((<a id='3084' tid='3083' class='u'>paredit-in-comment-p</a>)
         (<a id='3086' tid='3085' class='u'>insert</a> <a id='3088' tid='3087' class='u'>?\&quot;</a> ))
        ((<a id='3090' tid='3089' class='u'>not</a> (<a id='3092' tid='3091' class='u'>paredit-in-char-p</a>))
         (<a id='3094' tid='3093' class='u'>paredit-insert-pair</a> <a id='3096' tid='3095' class='u'>n</a> <a id='3098' tid='3097' class='u'>?\&quot;</a> <a id='3100' tid='3099' class='u'>?\&quot;</a> <a id='3102' tid='3101' class='u'>&#39;</a><a id='3104' tid='3103' class='u'>paredit-forward-for-quote</a>))))

(<a id='5208' tid='5207' class='u'>defun</a> <a id='5210' tid='5209' class='u'>paredit-meta-doublequote</a> (<a id='5212' tid='5211' class='u'>&optional</a> <a id='5214' tid='5213' class='u'>n</a>)
  <a id='5216' tid='5215' class='u'>&quot;Move to the end of the string, insert a newline, and indent.
If not in a string, act as `paredit-doublequote&#39;; if no prefix argument
  is specified and the region is not active or `transient-mark-mode&#39; is
  disabled, the default is to wrap one S-expression, however, not
  zero.&quot;</a>
  (<a id='5218' tid='5217' class='u'>interactive</a> <a id='5220' tid='5219' class='u'>&quot;P&quot;</a>)
  (<a id='5222' tid='5221' class='u'>if</a> (<a id='5224' tid='5223' class='u'>not</a> (<a id='5226' tid='5225' class='u'>paredit-in-string-p</a>))
      (<a id='5228' tid='5227' class='u'>paredit-doublequote</a> (<a id='5230' tid='5229' class='u'>or</a> <a id='5232' tid='5231' class='u'>n</a>
                               (<a id='5234' tid='5233' class='u'>and</a> (<a id='5236' tid='5235' class='u'>not</a> (<a id='5238' tid='5237' class='u'>paredit-region-active-p</a>))
                                    <a id='5240' tid='5239' class='u'>1</a>)))
    (<a id='5242' tid='5241' class='u'>let</a> ((<a id='5244' tid='5243' class='u'>start+end</a> (<a id='5246' tid='5245' class='u'>paredit-string-start+end-points</a>)))
      (<a id='5248' tid='5247' class='u'>goto-char</a> (<a id='5250' tid='5249' class='u'>1+</a> (<a id='5252' tid='5251' class='u'>cdr</a> <a id='5254' tid='5253' class='u'>start+end</a>)))
      (<a id='5256' tid='5255' class='u'>newline</a>)
      (<a id='5258' tid='5257' class='u'>lisp-indent-line</a>)
      (<a id='5260' tid='5259' class='u'>paredit-ignore-sexp-errors</a> (<a id='5262' tid='5261' class='u'>indent-sexp</a>)))))

(<a id='3374' tid='3373' class='u'>defun</a> <a id='3376' tid='3375' class='u'>paredit-forward-for-quote</a> (<a id='3378' tid='3377' class='u'>end</a>)
  (<a id='3380' tid='3379' class='u'>let</a> ((<a id='3382' tid='3381' class='u'>state</a> (<a id='3384' tid='3383' class='u'>paredit-current-parse-state</a>)))
    (<a id='3386' tid='3385' class='u'>while</a> (<a id='3388' tid='3387' class='u'>&lt;</a> (<a id='3390' tid='3389' class='u'>point</a>) <a id='3392' tid='3391' class='u'>end</a>)
      (<a id='3394' tid='3393' class='u'>let</a> ((<a id='3396' tid='3395' class='u'>new-state</a> (<a id='3398' tid='3397' class='u'>parse-partial-sexp</a> (<a id='3400' tid='3399' class='u'>point</a>) (<a id='3402' tid='3401' class='u'>1+</a> (<a id='3404' tid='3403' class='u'>point</a>))
                                           <a id='3406' tid='3405' class='u'>nil</a> <a id='3408' tid='3407' class='u'>nil</a> <a id='3410' tid='3409' class='u'>state</a>)))
        (<a id='3412' tid='3411' class='u'>if</a> (<a id='3414' tid='3413' class='u'>paredit-in-string-p</a> <a id='3416' tid='3415' class='u'>new-state</a>)
            (<a id='3418' tid='3417' class='u'>if</a> (<a id='3420' tid='3419' class='u'>not</a> (<a id='3422' tid='3421' class='u'>paredit-in-string-escape-p</a>))
                (<a id='3424' tid='3423' class='u'>setq</a> <a id='3426' tid='3425' class='u'>state</a> <a id='3428' tid='3427' class='u'>new-state</a>)
              <a id='3430' tid='3429' class='u'>;; Escape character: turn it into an escaped escape
</a>              <a id='3432' tid='3431' class='u'>;; character by appending another backslash.
</a>              (<a id='3434' tid='3433' class='u'>insert</a> <a id='3436' tid='3435' class='u'>?\\</a> )
              <a id='3438' tid='3437' class='u'>;; Now the point is after both escapes, and we want to
</a>              <a id='3440' tid='3439' class='u'>;; rescan from before the first one to after the second
</a>              <a id='3442' tid='3441' class='u'>;; one.
</a>              (<a id='3444' tid='3443' class='u'>setq</a> <a id='3446' tid='3445' class='u'>state</a>
                    (<a id='3448' tid='3447' class='u'>parse-partial-sexp</a> (<a id='3450' tid='3449' class='u'>-</a> (<a id='3452' tid='3451' class='u'>point</a>) <a id='3454' tid='3453' class='u'>2</a>) (<a id='3456' tid='3455' class='u'>point</a>)
                                        <a id='3458' tid='3457' class='u'>nil</a> <a id='3460' tid='3459' class='u'>nil</a> <a id='3462' tid='3461' class='u'>state</a>))
              <a id='3464' tid='3463' class='u'>;; Advance the end point, since we just inserted a new
</a>              <a id='3466' tid='3465' class='u'>;; character.
</a>              (<a id='3468' tid='3467' class='u'>setq</a> <a id='3470' tid='3469' class='u'>end</a> (<a id='3472' tid='3471' class='u'>1+</a> <a id='3474' tid='3473' class='u'>end</a>)))
          <a id='3476' tid='3475' class='u'>;; String: escape by inserting a backslash before the quote.
</a>          (<a id='3478' tid='3477' class='u'>backward-char</a>)
          (<a id='3480' tid='3479' class='u'>insert</a> <a id='3482' tid='3481' class='u'>?\\</a> )
          <a id='3484' tid='3483' class='u'>;; The point is now between the escape and the quote, and we
</a>          <a id='3486' tid='3485' class='u'>;; want to rescan from before the escape to after the quote.
</a>          (<a id='3488' tid='3487' class='u'>setq</a> <a id='3490' tid='3489' class='u'>state</a>
                (<a id='3492' tid='3491' class='u'>parse-partial-sexp</a> (<a id='3494' tid='3493' class='u'>1-</a> (<a id='3496' tid='3495' class='u'>point</a>)) (<a id='3498' tid='3497' class='u'>1+</a> (<a id='3500' tid='3499' class='u'>point</a>))
                                    <a id='3502' tid='3501' class='u'>nil</a> <a id='3504' tid='3503' class='u'>nil</a> <a id='3506' tid='3505' class='u'>state</a>))
          <a id='3508' tid='3507' class='u'>;; Advance the end point for the same reason as above.
</a>          (<a id='3510' tid='3509' class='u'>setq</a> <a id='3512' tid='3511' class='u'>end</a> (<a id='3514' tid='3513' class='u'>1+</a> <a id='3516' tid='3515' class='u'>end</a>)))))))

<span class='i'>;;;; Escape Insertion
</span>
(<a id='2026' tid='2025' class='u'>defun</a> <a id='2028' tid='2027' class='u'>paredit-backslash</a> ()
  <a id='2030' tid='2029' class='u'>&quot;Insert a backslash followed by a character to escape.&quot;</a>
  (<a id='2032' tid='2031' class='u'>interactive</a>)
  <span class='i'>(cond ((paredit-in-string-p) (paredit-backslash-interactive))
        ((paredit-in-comment-p) (insert ?\\))
        ((paredit-in-char-p) (forward-char) (paredit-backslash-interactive))
        (t (paredit-backslash-interactive)))</span>)

<span class='i'>(defun paredit-backslash-interactive ()
  (insert ?\\ )
  ;; Read a character to insert after the backslash.  If anything
  ;; goes wrong -- the user hits delete (entering the rubout
  ;; `character&#39;), aborts with C-g, or enters non-character input
  ;; -- then delete the backslash to avoid a dangling escape.
  (let ((delete-p t))
    (unwind-protect
        (let ((char (read-char &quot;Character to escape: &quot;)))
          (if (not (eq char ?\^?))
              (progn (message &quot;Character to escape: %c&quot; char)
                     (insert char)
                     (setq delete-p nil))))
      (if delete-p
          (progn (message &quot;Deleting escape.&quot;)
                 (backward-delete-char 1))))))</span>

(<a id='5460' tid='5459' class='u'>defun</a> <a id='5462' tid='5461' class='u'>paredit-newline</a> ()
  <a id='5464' tid='5463' class='u'>&quot;Insert a newline and indent it.
This is like `newline-and-indent&#39;, but it not only indents the line
  that the point is on but also the S-expression following the point,
  if there is one.
Move forward one character first if on an escaped character.
If in a string, just insert a literal newline.
If in a comment and if followed by invalid structure, call
  `indent-new-comment-line&#39; to keep the invalid structure in a
  comment.&quot;</a>
  (<a id='5466' tid='5465' class='u'>interactive</a>)
  (<span class='i'>cond</span> <span class='i'>((paredit-in-string-p)
         (newline))</span>
        <span class='i'>((paredit-in-comment-p)
         (if (paredit-region-ok-p (point) (point-at-eol))
             (progn (newline-and-indent)
                    (paredit-ignore-sexp-errors (indent-sexp)))
             (indent-new-comment-line)))</span>
        (<a id='1078' tid='1077' class='m'>t</a>
         (<a id='1080' tid='1079' class='m'>if</a> (<a id='1082' tid='1081' class='m'>paredit-in-char-p</a>)
             (<a id='1084' tid='1083' class='m'>forward-char</a>))
         (<a id='1086' tid='1085' class='m'>newline-and-indent</a>)
         <a id='1088' tid='1087' class='m'>;; Indent the following S-expression, but don&#39;t signal an
</a>         <a id='1090' tid='1089' class='m'>;; error if there&#39;s only a closing delimiter after the point.
</a>         (<a id='1092' tid='1091' class='m'>paredit-ignore-sexp-errors</a> (<a id='1094' tid='1093' class='m'>indent-sexp</a>)))))

(<a id='5838' tid='5837' class='u'>defun</a> <a id='5840' tid='5839' class='u'>paredit-reindent-defun</a> (<a id='5842' tid='5841' class='u'>&optional</a> <a id='5844' tid='5843' class='u'>argument</a>)
  <a id='5846' tid='5845' class='u'>&quot;Reindent the definition that the point is on.
If the point is in a string or a comment, fill the paragraph instead,
  and with a prefix argument, justify as well.&quot;</a>
  (<a id='5848' tid='5847' class='u'>interactive</a> <a id='5850' tid='5849' class='u'>&quot;P&quot;</a>)
  <span class='i'>(if (or (paredit-in-string-p)
          (paredit-in-comment-p))
      (lisp-fill-paragraph argument)
    (let ((column (current-column))
          (indentation (paredit-current-indentation)))
      (save-excursion (end-of-defun) (beginning-of-defun) (indent-sexp))
      ;; Preserve the point&#39;s position either in the indentation or in
      ;; the code: if on code, move with the code; if in indentation,
      ;; leave it in the indentation, either where it was (if that&#39;s
      ;; still indentation) or at the end of the indentation (if the
      ;; code moved far enough left).
      (let ((indentation* (paredit-current-indentation)))
        (goto-char
         (+ (point-at-bol)
            (cond ((not (&lt; column indentation))
                   (+ column (- indentation* indentation)))
                  ((&lt;= indentation* column) indentation*)
                  (t column)))))))</span>)

<span class='i'>;;;; Comment Insertion
</span>
(<a id='5852' tid='5851' class='u'>defun</a> <a id='5854' tid='5853' class='u'>paredit-semicolon</a> (<a id='5856' tid='5855' class='u'>&optional</a> <a id='5858' tid='5857' class='u'>n</a>)
  <a id='5860' tid='5859' class='u'>&quot;Insert a semicolon.
With a prefix argument N, insert N semicolons.
If in a string, do just that and nothing else.
If in a character literal, move to the beginning of the character
  literal before inserting the semicolon.
If the enclosing list ends on the line after the point, break the line
  after the last S-expression following the point.
If a list begins on the line after the point but ends on a different
  line, break the line after the last S-expression following the point
  before the list.&quot;</a>
  (<a id='5862' tid='5861' class='u'>interactive</a> <a id='5864' tid='5863' class='u'>&quot;p&quot;</a>)
  (<a id='5866' tid='5865' class='u'>if</a> (<a id='5868' tid='5867' class='u'>or</a> (<a id='5870' tid='5869' class='u'>paredit-in-string-p</a>) (<a id='5872' tid='5871' class='u'>paredit-in-comment-p</a>))
      (<a id='5874' tid='5873' class='u'>insert</a> (<a id='5876' tid='5875' class='u'>make-string</a> (<a id='5878' tid='5877' class='u'>or</a> <a id='5880' tid='5879' class='u'>n</a> <a id='5882' tid='5881' class='u'>1</a>) <a id='5884' tid='5883' class='u'>?\;</a> ))
    (<a id='5886' tid='5885' class='u'>if</a> (<a id='5888' tid='5887' class='u'>paredit-in-char-p</a>)
        (<a id='5890' tid='5889' class='u'>backward-char</a> <a id='5892' tid='5891' class='u'>2</a>))
    (<a id='5894' tid='5893' class='u'>let</a> ((<a id='5896' tid='5895' class='u'>line-break-point</a> (<a id='5898' tid='5897' class='u'>paredit-semicolon-find-line-break-point</a>)))
      (<a id='5900' tid='5899' class='u'>if</a> <a id='5902' tid='5901' class='u'>line-break-point</a>
          (<a id='5904' tid='5903' class='u'>paredit-semicolon-with-line-break</a> <a id='5906' tid='5905' class='u'>line-break-point</a> (<a id='5908' tid='5907' class='u'>or</a> <a id='5910' tid='5909' class='u'>n</a> <a id='5912' tid='5911' class='u'>1</a>))
          (<a id='5914' tid='5913' class='u'>insert</a> (<a id='5916' tid='5915' class='u'>make-string</a> (<a id='5918' tid='5917' class='u'>or</a> <a id='5920' tid='5919' class='u'>n</a> <a id='5922' tid='5921' class='u'>1</a>) <a id='5924' tid='5923' class='u'>?\;</a> ))))))

(<a id='5926' tid='5925' class='u'>defun</a> <a id='5928' tid='5927' class='u'>paredit-semicolon-find-line-break-point</a> ()
  (<a id='1096' tid='1095' class='m'>let</a> ((<a id='1098' tid='1097' class='m'>line-break-point</a> <a id='1100' tid='1099' class='m'>nil</a>)
        (<a id='1102' tid='1101' class='m'>eol</a> (<a id='1104' tid='1103' class='m'>point-at-eol</a>)))
    (<span class='i'>and</span> <span class='i'>(not (eolp))</span>                   <span class='i'>;Implies (not (eobp)).
</span>         (<span class='i'>save-excursion</span>
           (<a id='550' tid='549' class='m'>paredit-handle-sexp-errors</a>
               (<span class='i'>progn</span>
                 (<a id='1106' tid='1105' class='m'>while</a>
                     (<a id='1108' tid='1107' class='m'>progn</a>
                       (<a id='1110' tid='1109' class='m'>setq</a> <a id='1112' tid='1111' class='m'>line-break-point</a> (<a id='1114' tid='1113' class='m'>point</a>))
                       (<a id='1116' tid='1115' class='m'>forward-sexp</a>)
                       (<a id='1118' tid='1117' class='m'>and</a> (<a id='1120' tid='1119' class='m'>eq</a> <a id='1122' tid='1121' class='m'>eol</a> (<a id='1124' tid='1123' class='m'>point-at-eol</a>))
                            (<a id='1126' tid='1125' class='m'>not</a> (<a id='1128' tid='1127' class='m'>eobp</a>)))))
                 <span class='i'>(backward-sexp)</span>
                 <span class='i'>(and (eq eol (point-at-eol))
                      ;; Don&#39;t break the line if the end of the last
                      ;; S-expression is at the end of the buffer.
                      (progn (forward-sexp) (not (eobp))))</span>)
             <a id='552' tid='551' class='m'>;; If we hit the end of an expression, but the closing
</a>             <a id='554' tid='553' class='m'>;; delimiter is on another line, don&#39;t break the line.
</a>             (<a id='556' tid='555' class='m'>save-excursion</a>
               (<a id='558' tid='557' class='m'>paredit-skip-whitespace</a> <a id='560' tid='559' class='m'>t</a> (<a id='562' tid='561' class='m'>point-at-eol</a>))
               (<a id='564' tid='563' class='m'>not</a> (<a id='566' tid='565' class='m'>or</a> (<a id='568' tid='567' class='m'>eolp</a>) (<a id='570' tid='569' class='m'>eq</a> (<a id='572' tid='571' class='m'>char-after</a>) <a id='574' tid='573' class='m'>?\;</a> ))))))
         <span class='i'>line-break-point</span>)))

(<a id='5930' tid='5929' class='u'>defun</a> <a id='5932' tid='5931' class='u'>paredit-semicolon-with-line-break</a> (<a id='5934' tid='5933' class='u'>line-break-point</a> <a id='5936' tid='5935' class='u'>n</a>)
  (<a id='5938' tid='5937' class='u'>let</a> ((<a id='5940' tid='5939' class='u'>line-break-marker</a> (<a id='5942' tid='5941' class='u'>make-marker</a>)))
    (<a id='5944' tid='5943' class='u'>set-marker</a> <a id='5946' tid='5945' class='u'>line-break-marker</a> <a id='5948' tid='5947' class='u'>line-break-point</a>)
    (<a id='5950' tid='5949' class='u'>set-marker-insertion-type</a> <a id='5952' tid='5951' class='u'>line-break-marker</a> <a id='5954' tid='5953' class='u'>t</a>)
    (<a id='5956' tid='5955' class='u'>insert</a> (<a id='5958' tid='5957' class='u'>make-string</a> (<a id='5960' tid='5959' class='u'>or</a> <a id='5962' tid='5961' class='u'>n</a> <a id='5964' tid='5963' class='u'>1</a>) <a id='5966' tid='5965' class='u'>?\;</a> ))
    (<a id='5968' tid='5967' class='u'>save-excursion</a>
      (<a id='5970' tid='5969' class='u'>goto-char</a> <a id='5972' tid='5971' class='u'>line-break-marker</a>)
      (<a id='5974' tid='5973' class='u'>set-marker</a> <a id='5976' tid='5975' class='u'>line-break-marker</a> <a id='5978' tid='5977' class='u'>nil</a>)
      (<a id='5980' tid='5979' class='u'>newline</a>)
      (<a id='5982' tid='5981' class='u'>lisp-indent-line</a>)
      <a id='5984' tid='5983' class='u'>;; This step is redundant if we are inside a list, but even if we
</a>      <a id='5986' tid='5985' class='u'>;; are at the top level, we want at least to indent whatever we
</a>      <a id='5988' tid='5987' class='u'>;; bumped off the line.
</a>      (<a id='5990' tid='5989' class='u'>paredit-ignore-sexp-errors</a> (<a id='5992' tid='5991' class='u'>indent-sexp</a>))
      (<a id='5994' tid='5993' class='u'>paredit-indent-sexps</a>))))

<span class='i'>;;; This is all a horrible, horrible hack, primarily for GNU Emacs 21,
</span><span class='i'>;;; in which there is no `comment-or-uncomment-region&#39;.
</span>
(<a id='7304' tid='7303' class='u'>autoload</a> <a id='7306' tid='7305' class='u'>&#39;</a><a id='7308' tid='7307' class='u'>comment-forward</a> <a id='7310' tid='7309' class='u'>&quot;newcomment&quot;</a>)
(<a id='7312' tid='7311' class='u'>autoload</a> <a id='7314' tid='7313' class='u'>&#39;</a><a id='7316' tid='7315' class='u'>comment-normalize-vars</a> <a id='7318' tid='7317' class='u'>&quot;newcomment&quot;</a>)
(<a id='7320' tid='7319' class='u'>autoload</a> <a id='7322' tid='7321' class='u'>&#39;</a><a id='7324' tid='7323' class='u'>comment-region</a> <a id='7326' tid='7325' class='u'>&quot;newcomment&quot;</a>)
(<a id='7328' tid='7327' class='u'>autoload</a> <a id='7330' tid='7329' class='u'>&#39;</a><a id='7332' tid='7331' class='u'>comment-search-forward</a> <a id='7334' tid='7333' class='u'>&quot;newcomment&quot;</a>)
(<a id='7336' tid='7335' class='u'>autoload</a> <a id='7338' tid='7337' class='u'>&#39;</a><a id='7340' tid='7339' class='u'>uncomment-region</a> <a id='7342' tid='7341' class='u'>&quot;newcomment&quot;</a>)

(<a id='4172' tid='4171' class='u'>defun</a> <a id='4174' tid='4173' class='u'>paredit-initialize-comment-dwim</a> ()
  (<a id='4176' tid='4175' class='u'>require</a> <a id='4178' tid='4177' class='u'>&#39;</a><a id='4180' tid='4179' class='u'>newcomment</a>)
  (<a id='4182' tid='4181' class='u'>if</a> (<a id='4184' tid='4183' class='u'>not</a> (<a id='4186' tid='4185' class='u'>fboundp</a> <a id='4188' tid='4187' class='u'>&#39;</a><a id='4190' tid='4189' class='u'>comment-or-uncomment-region</a>))
      (<a id='4192' tid='4191' class='u'>defalias</a> <a id='4194' tid='4193' class='u'>&#39;</a><a id='4196' tid='4195' class='u'>comment-or-uncomment-region</a>
        (<a id='4198' tid='4197' class='u'>lambda</a> (<a id='4200' tid='4199' class='u'>beginning</a> <a id='4202' tid='4201' class='u'>end</a> <a id='4204' tid='4203' class='u'>&optional</a> <a id='4206' tid='4205' class='u'>argument</a>)
          (<a id='4208' tid='4207' class='u'>interactive</a> <a id='4210' tid='4209' class='u'>&quot;*r\nP&quot;</a>)
          (<a id='4212' tid='4211' class='u'>if</a> (<a id='4214' tid='4213' class='u'>save-excursion</a> (<a id='4216' tid='4215' class='u'>goto-char</a> <a id='4218' tid='4217' class='u'>beginning</a>)
                              (<a id='4220' tid='4219' class='u'>comment-forward</a> (<a id='4222' tid='4221' class='u'>point-max</a>))
                              (<a id='4224' tid='4223' class='u'>&lt;=</a> <a id='4226' tid='4225' class='u'>end</a> (<a id='4228' tid='4227' class='u'>point</a>)))
              (<a id='4230' tid='4229' class='u'>uncomment-region</a> <a id='4232' tid='4231' class='u'>beginning</a> <a id='4234' tid='4233' class='u'>end</a> <a id='4236' tid='4235' class='u'>argument</a>)
              (<a id='4238' tid='4237' class='u'>comment-region</a> <a id='4240' tid='4239' class='u'>beginning</a> <a id='4242' tid='4241' class='u'>end</a> <a id='4244' tid='4243' class='u'>argument</a>)))))
  (<a id='4246' tid='4245' class='u'>defalias</a> <a id='4248' tid='4247' class='u'>&#39;</a><a id='4250' tid='4249' class='u'>paredit-initialize-comment-dwim</a> <a id='4252' tid='4251' class='u'>&#39;</a><a id='4254' tid='4253' class='u'>comment-normalize-vars</a>)
  (<a id='4256' tid='4255' class='u'>comment-normalize-vars</a>))

(<a id='2626' tid='2625' class='u'>defun</a> <a id='2628' tid='2627' class='u'>paredit-comment-dwim</a> (<a id='2630' tid='2629' class='u'>&optional</a> <a id='2632' tid='2631' class='u'>argument</a>)
  <a id='2634' tid='2633' class='u'>&quot;Call the Lisp comment command you want (Do What I Mean).
This is like `comment-dwim&#39;, but it is specialized for Lisp editing.
If transient mark mode is enabled and the mark is active, comment or
  uncomment the selected region, depending on whether it was entirely
  commented not not already.
If there is already a comment on the current line, with no prefix
  argument, indent to that comment; with a prefix argument, kill that
  comment.
Otherwise, insert a comment appropriate for the context and ensure that
  any code following the comment is moved to the next line.
At the top level, where indentation is calculated to be at column 0,
  insert a triple-semicolon comment; within code, where the indentation
  is calculated to be non-zero, and on the line there is either no code
  at all or code after the point, insert a double-semicolon comment;
  and if the point is after all code on the line, insert a single-
  semicolon margin comment at `comment-column&#39;.&quot;</a>
  (<a id='2636' tid='2635' class='u'>interactive</a> <a id='2638' tid='2637' class='u'>&quot;*P&quot;</a>)
  (<a id='2640' tid='2639' class='u'>paredit-initialize-comment-dwim</a>)
  (<a id='2642' tid='2641' class='u'>cond</a> ((<a id='2644' tid='2643' class='u'>paredit-region-active-p</a>)
         (<a id='2646' tid='2645' class='u'>comment-or-uncomment-region</a> (<a id='2648' tid='2647' class='u'>region-beginning</a>)
                                      (<a id='2650' tid='2649' class='u'>region-end</a>)
                                      <a id='2652' tid='2651' class='u'>argument</a>))
        ((<a id='2654' tid='2653' class='u'>paredit-comment-on-line-p</a>)
         (<a id='2656' tid='2655' class='u'>if</a> <a id='2658' tid='2657' class='u'>argument</a>
             (<a id='2660' tid='2659' class='u'>comment-kill</a> (<a id='2662' tid='2661' class='u'>if</a> (<a id='2664' tid='2663' class='u'>integerp</a> <a id='2666' tid='2665' class='u'>argument</a>) <a id='2668' tid='2667' class='u'>argument</a> <a id='2670' tid='2669' class='u'>nil</a>))
             (<a id='2672' tid='2671' class='u'>comment-indent</a>)))
        (<a id='2674' tid='2673' class='u'>t</a> (<a id='2676' tid='2675' class='u'>paredit-insert-comment</a>))))

(<a id='2678' tid='2677' class='u'>defun</a> <a id='2680' tid='2679' class='u'>paredit-comment-on-line-p</a> ()
  <a id='2682' tid='2681' class='u'>&quot;True if there is a comment on the line following point.
This is expected to be called only in `paredit-comment-dwim&#39;; do not
  call it elsewhere.&quot;</a>
  (<a id='2684' tid='2683' class='u'>save-excursion</a>
    (<a id='2686' tid='2685' class='u'>beginning-of-line</a>)
    (<a id='2688' tid='2687' class='u'>let</a> ((<a id='2690' tid='2689' class='u'>comment-p</a> <a id='2692' tid='2691' class='u'>nil</a>))
      <a id='2694' tid='2693' class='u'>;; Search forward for a comment beginning.  If there is one, set
</a>      <a id='2696' tid='2695' class='u'>;; COMMENT-P to true; if not, it will be nil.
</a>      (<a id='2698' tid='2697' class='u'>while</a> (<a id='2700' tid='2699' class='u'>progn</a>
               (<a id='2702' tid='2701' class='u'>setq</a> <a id='2704' tid='2703' class='u'>comment-p</a>          <a id='2706' tid='2705' class='u'>;t -&gt; no error
</a>                     (<a id='2708' tid='2707' class='u'>comment-search-forward</a> (<a id='2710' tid='2709' class='u'>point-at-eol</a>) <a id='2712' tid='2711' class='u'>t</a>))
               (<a id='2714' tid='2713' class='u'>and</a> <a id='2716' tid='2715' class='u'>comment-p</a>
                    (<a id='2718' tid='2717' class='u'>or</a> (<a id='2720' tid='2719' class='u'>paredit-in-string-p</a>)
                        (<a id='2722' tid='2721' class='u'>paredit-in-char-p</a> (<a id='2724' tid='2723' class='u'>1-</a> (<a id='2726' tid='2725' class='u'>point</a>))))))
        (<a id='2728' tid='2727' class='u'>forward-char</a>))
      <a id='2730' tid='2729' class='u'>comment-p</a>)))

(<a id='4258' tid='4257' class='u'>defun</a> <a id='4260' tid='4259' class='u'>paredit-insert-comment</a> ()
  (<a id='1130' tid='1129' class='m'>let</a> ((<a id='1132' tid='1131' class='m'>code-after-p</a>
         (<a id='1134' tid='1133' class='m'>save-excursion</a> (<a id='1136' tid='1135' class='m'>paredit-skip-whitespace</a> <a id='1138' tid='1137' class='m'>t</a> (<a id='1140' tid='1139' class='m'>point-at-eol</a>))
                         (<a id='1142' tid='1141' class='m'>not</a> (<a id='1144' tid='1143' class='m'>eolp</a>))))
        (<a id='1146' tid='1145' class='m'>code-before-p</a>
         (<a id='1148' tid='1147' class='m'>save-excursion</a> (<a id='1150' tid='1149' class='m'>paredit-skip-whitespace</a> <a id='1152' tid='1151' class='m'>nil</a> (<a id='1154' tid='1153' class='m'>point-at-bol</a>))
                         (<a id='1156' tid='1155' class='m'>not</a> (<a id='1158' tid='1157' class='m'>bolp</a>)))))
    (<a id='1160' tid='1159' class='m'>cond</a> ((<a id='1162' tid='1161' class='m'>and</a> (<a id='1164' tid='1163' class='m'>bolp</a>)
                (<a id='1166' tid='1165' class='m'>let</a> ((<a id='1168' tid='1167' class='m'>indent</a>
                       (<a id='1170' tid='1169' class='m'>let</a> ((<a id='1172' tid='1171' class='m'>indent</a> (<a id='1174' tid='1173' class='m'>calculate-lisp-indent</a>)))
                         (<a id='1176' tid='1175' class='m'>if</a> (<a id='1178' tid='1177' class='m'>consp</a> <a id='1180' tid='1179' class='m'>indent</a>) (<a id='1182' tid='1181' class='m'>car</a> <a id='1184' tid='1183' class='m'>indent</a>) <a id='1186' tid='1185' class='m'>indent</a>))))
                  (<a id='1188' tid='1187' class='m'>and</a> <a id='1190' tid='1189' class='m'>indent</a> (<a id='1192' tid='1191' class='m'>zerop</a> <a id='1194' tid='1193' class='m'>indent</a>))))
           <a id='1196' tid='1195' class='m'>;; Top-level comment
</a>           (<a id='1198' tid='1197' class='m'>if</a> <a id='1200' tid='1199' class='m'>code-after-p</a> (<a id='1202' tid='1201' class='m'>save-excursion</a> (<a id='1204' tid='1203' class='m'>newline</a>)))
           (<a id='1206' tid='1205' class='m'>insert</a> <a id='1208' tid='1207' class='m'>&quot;;;; &quot;</a>))
          (<span class='i'>(or code-after-p (not code-before-p))</span>
           <span class='i'>;; Code comment
</span>           <span class='i'>(if code-before-p
               (newline-and-indent)
               (lisp-indent-line))</span>
           <span class='i'>(insert &quot;;; &quot;)</span>
           (<a id='1210' tid='1209' class='m'>if</a> <a id='1212' tid='1211' class='m'>code-after-p</a>
               (<a id='1214' tid='1213' class='m'>save-excursion</a>
                 (<a id='1216' tid='1215' class='m'>newline</a>)
                 (<a id='1218' tid='1217' class='m'>lisp-indent-line</a>)
                 (<a id='1220' tid='1219' class='m'>paredit-indent-sexps</a>))))
          (<a id='1222' tid='1221' class='m'>t</a>
           <a id='1224' tid='1223' class='m'>;; Margin comment
</a>           (<a id='1226' tid='1225' class='m'>indent-to</a> <a id='1228' tid='1227' class='m'>comment-column</a> <a id='1230' tid='1229' class='m'>1</a>) <a id='1232' tid='1231' class='m'>; 1 -&gt; force one leading space
</a>           (<a id='1234' tid='1233' class='m'>insert</a> <a id='1236' tid='1235' class='m'>?\;</a> )))))

<a id='7344' tid='7343' class='u'>;;;; Character Deletion
</a>
(<a id='3232' tid='3231' class='u'>defun</a> <a id='3234' tid='3233' class='u'>paredit-forward-delete</a> (<a id='3236' tid='3235' class='u'>&optional</a> <a id='3238' tid='3237' class='u'>argument</a>)
  <a id='3240' tid='3239' class='u'>&quot;Delete a character forward or move forward over a delimiter.
If on an opening S-expression delimiter, move forward into the
  S-expression.
If on a closing S-expression delimiter, refuse to delete unless the
  S-expression is empty, in which case delete the whole S-expression.
With a numeric prefix argument N, delete N characters forward.
With a `C-u&#39; prefix argument, simply delete a character forward,
  without regard for delimiter balancing.&quot;</a>
  (<a id='3242' tid='3241' class='u'>interactive</a> <a id='3244' tid='3243' class='u'>&quot;P&quot;</a>)
  (<span class='i'>cond</span> ((<a id='1238' tid='1237' class='m'>or</a> (<a id='1240' tid='1239' class='m'>consp</a> <a id='1242' tid='1241' class='m'>argument</a>) (<a id='1244' tid='1243' class='m'>eobp</a>))
         (<a id='1246' tid='1245' class='m'>delete-char</a> <a id='1248' tid='1247' class='m'>1</a>))
        ((<a id='576' tid='575' class='m'>integerp</a> <a id='578' tid='577' class='m'>argument</a>)
         (<a id='580' tid='579' class='m'>if</a> (<a id='582' tid='581' class='m'>&lt;</a> <a id='584' tid='583' class='m'>argument</a> <a id='586' tid='585' class='m'>0</a>)
             (<a id='588' tid='587' class='m'>paredit-backward-delete</a> <a id='590' tid='589' class='m'>argument</a>)
             (<a id='592' tid='591' class='m'>while</a> (<a id='594' tid='593' class='m'>&gt;</a> <a id='596' tid='595' class='m'>argument</a> <a id='598' tid='597' class='m'>0</a>)
               (<a id='600' tid='599' class='m'>paredit-forward-delete</a>)
               (<a id='602' tid='601' class='m'>setq</a> <a id='604' tid='603' class='m'>argument</a> (<a id='606' tid='605' class='m'>-</a> <a id='608' tid='607' class='m'>argument</a> <a id='610' tid='609' class='m'>1</a>)))))
        <span class='i'>((paredit-in-string-p)
         (paredit-forward-delete-in-string))</span>
        <span class='i'>((paredit-in-comment-p)
         (paredit-forward-delete-in-comment))</span>
        ((<a id='472' tid='471' class='m'>paredit-in-char-p</a>)            <a id='474' tid='473' class='m'>; Escape -- delete both chars.
</a>         (<a id='476' tid='475' class='m'>backward-delete-char</a> <a id='478' tid='477' class='m'>1</a>)
         (<a id='480' tid='479' class='m'>delete-char</a> <a id='482' tid='481' class='m'>1</a>))
        ((<a id='438' tid='437' class='m'>eq</a> (<a id='440' tid='439' class='m'>char-after</a>) <a id='442' tid='441' class='m'>?\\</a> )         <a id='444' tid='443' class='m'>; ditto
</a>         (<a id='446' tid='445' class='m'>delete-char</a> <a id='448' tid='447' class='m'>2</a>))
        ((<a id='334' tid='333' class='m'>let</a> ((<a id='336' tid='335' class='m'>syn</a> (<a id='338' tid='337' class='m'>char-syntax</a> (<a id='340' tid='339' class='m'>char-after</a>))))
           (<a id='342' tid='341' class='m'>or</a> (<a id='344' tid='343' class='m'>eq</a> <a id='346' tid='345' class='m'>syn</a> <a id='348' tid='347' class='m'>?\(</a> )
               (<a id='350' tid='349' class='m'>eq</a> <a id='352' tid='351' class='m'>syn</a> <a id='354' tid='353' class='m'>?\&quot;</a> )))
         (<a id='356' tid='355' class='m'>if</a> (<a id='358' tid='357' class='m'>save-excursion</a>
               (<a id='360' tid='359' class='m'>paredit-handle-sexp-errors</a> (<a id='362' tid='361' class='m'>progn</a> (<a id='364' tid='363' class='m'>forward-sexp</a>) <a id='366' tid='365' class='m'>t</a>)
                 <a id='368' tid='367' class='m'>nil</a>))
             (<a id='370' tid='369' class='m'>forward-char</a>)
           (<a id='372' tid='371' class='m'>message</a> <a id='374' tid='373' class='m'>&quot;Deleting spurious opening delimiter.&quot;</a>)
           (<a id='376' tid='375' class='m'>delete-char</a> <a id='378' tid='377' class='m'>1</a>)))
        ((<a id='252' tid='251' class='m'>and</a> (<a id='254' tid='253' class='m'>not</a> (<a id='256' tid='255' class='m'>paredit-in-char-p</a> (<a id='258' tid='257' class='m'>1-</a> (<a id='260' tid='259' class='m'>point</a>))))
              (<a id='262' tid='261' class='m'>eq</a> (<a id='264' tid='263' class='m'>char-syntax</a> (<a id='266' tid='265' class='m'>char-after</a>)) <a id='268' tid='267' class='m'>?\)</a> )
              (<a id='270' tid='269' class='m'>eq</a> (<a id='272' tid='271' class='m'>char-before</a>) (<a id='274' tid='273' class='m'>matching-paren</a> (<a id='276' tid='275' class='m'>char-after</a>))))
         (<a id='278' tid='277' class='m'>backward-delete-char</a> <a id='280' tid='279' class='m'>1</a>)       <a id='282' tid='281' class='m'>; Empty list -- delete both
</a>         (<a id='284' tid='283' class='m'>delete-char</a> <a id='286' tid='285' class='m'>1</a>))               <span class='i'>;   delimiters.
</span>        <span class='i'>((eq ?\; (char-after))
         (paredit-forward-delete-comment-start))</span>
        <span class='i'>;; Just delete a single character, if it&#39;s not a closing
</span>        <span class='i'>;; delimiter.  (The character literal case is already handled
</span>        <span class='i'>;; by now.)
</span>        ((<a id='198' tid='197' class='m'>not</a> (<a id='200' tid='199' class='m'>eq</a> (<a id='202' tid='201' class='m'>char-syntax</a> (<a id='204' tid='203' class='m'>char-after</a>)) <a id='206' tid='205' class='m'>?\)</a> ))
         (<a id='208' tid='207' class='m'>delete-char</a> <a id='210' tid='209' class='m'>1</a>))))

(<a id='3246' tid='3245' class='u'>defun</a> <a id='3248' tid='3247' class='u'>paredit-forward-delete-in-string</a> ()
  (<a id='3250' tid='3249' class='u'>let</a> ((<a id='3252' tid='3251' class='u'>start+end</a> (<a id='3254' tid='3253' class='u'>paredit-string-start+end-points</a>)))
    (<a id='3256' tid='3255' class='u'>cond</a> ((<a id='3258' tid='3257' class='u'>not</a> (<a id='3260' tid='3259' class='u'>eq</a> (<a id='3262' tid='3261' class='u'>point</a>) (<a id='3264' tid='3263' class='u'>cdr</a> <a id='3266' tid='3265' class='u'>start+end</a>)))
           <a id='3268' tid='3267' class='u'>;; If it&#39;s not the close-quote, it&#39;s safe to delete.  But
</a>           <a id='3270' tid='3269' class='u'>;; first handle the case that we&#39;re in a string escape.
</a>           (<a id='3272' tid='3271' class='u'>cond</a> ((<a id='3274' tid='3273' class='u'>paredit-in-string-escape-p</a>)
                  <a id='3276' tid='3275' class='u'>;; We&#39;re right after the backslash, so backward
</a>                  <a id='3278' tid='3277' class='u'>;; delete it before deleting the escaped character.
</a>                  (<a id='3280' tid='3279' class='u'>backward-delete-char</a> <a id='3282' tid='3281' class='u'>1</a>))
                 ((<a id='3284' tid='3283' class='u'>eq</a> (<a id='3286' tid='3285' class='u'>char-after</a>) <a id='3288' tid='3287' class='u'>?\\</a> )
                  <a id='3290' tid='3289' class='u'>;; If we&#39;re not in a string escape, but we are on a
</a>                  <a id='3292' tid='3291' class='u'>;; backslash, it must start the escape for the next
</a>                  <a id='3294' tid='3293' class='u'>;; character, so delete the backslash before deleting
</a>                  <a id='3296' tid='3295' class='u'>;; the next character.
</a>                  (<a id='3298' tid='3297' class='u'>delete-char</a> <a id='3300' tid='3299' class='u'>1</a>)))
           (<a id='3302' tid='3301' class='u'>delete-char</a> <a id='3304' tid='3303' class='u'>1</a>))
          ((<a id='3306' tid='3305' class='u'>eq</a> (<a id='3308' tid='3307' class='u'>1-</a> (<a id='3310' tid='3309' class='u'>point</a>)) (<a id='3312' tid='3311' class='u'>car</a> <a id='3314' tid='3313' class='u'>start+end</a>))
           <a id='3316' tid='3315' class='u'>;; If it is the close-quote, delete only if we&#39;re also right
</a>           <a id='3318' tid='3317' class='u'>;; past the open-quote (i.e. it&#39;s empty), and then delete
</a>           <a id='3320' tid='3319' class='u'>;; both quotes.  Otherwise we refuse to delete it.
</a>           (<a id='3322' tid='3321' class='u'>backward-delete-char</a> <a id='3324' tid='3323' class='u'>1</a>)
           (<a id='3326' tid='3325' class='u'>delete-char</a> <a id='3328' tid='3327' class='u'>1</a>)))))

<span class='i'>(defun paredit-forward-delete-in-comment ()
  ;; Point is in a comment, possibly at eol.  Refuse to delete a
  ;; comment end if moving the next line into the comment would break
  ;; structure.
  (if (eolp)
      (let ((next-line-start (point-at-bol 2))
            (next-line-end (point-at-eol 2)))
        (paredit-check-region next-line-start next-line-end)))
  (delete-char 1))</span>

<span class='i'>(defun paredit-forward-delete-comment-start ()
  ;; Point precedes a comment start (not at eol).  Refuse to delete a
  ;; comment start if the comment contains unbalanced junk.
  (paredit-check-region (+ (point) 1) (point-at-eol))
  (delete-char 1))</span>

(<a id='2108' tid='2107' class='u'>defun</a> <a id='2110' tid='2109' class='u'>paredit-backward-delete</a> (<a id='2112' tid='2111' class='u'>&optional</a> <a id='2114' tid='2113' class='u'>argument</a>)
  <a id='2116' tid='2115' class='u'>&quot;Delete a character backward or move backward over a delimiter.
If on a closing S-expression delimiter, move backward into the
  S-expression.
If on an opening S-expression delimiter, refuse to delete unless the
  S-expression is empty, in which case delete the whole S-expression.
With a numeric prefix argument N, delete N characters backward.
With a `C-u&#39; prefix argument, simply delete a character backward,
  without regard for delimiter balancing.&quot;</a>
  (<a id='2118' tid='2117' class='u'>interactive</a> <a id='2120' tid='2119' class='u'>&quot;P&quot;</a>)
  (<span class='i'>cond</span> ((<a id='1250' tid='1249' class='m'>or</a> (<a id='1252' tid='1251' class='m'>consp</a> <a id='1254' tid='1253' class='m'>argument</a>) (<a id='1256' tid='1255' class='m'>bobp</a>))
         <a id='1258' tid='1257' class='m'>;++ Should this untabify?
</a>         (<a id='1260' tid='1259' class='m'>backward-delete-char</a> <a id='1262' tid='1261' class='m'>1</a>))
        ((<a id='612' tid='611' class='m'>integerp</a> <a id='614' tid='613' class='m'>argument</a>)
         (<a id='616' tid='615' class='m'>if</a> (<a id='618' tid='617' class='m'>&lt;</a> <a id='620' tid='619' class='m'>argument</a> <a id='622' tid='621' class='m'>0</a>)
             (<a id='624' tid='623' class='m'>paredit-forward-delete</a> (<a id='626' tid='625' class='m'>-</a> <a id='628' tid='627' class='m'>0</a> <a id='630' tid='629' class='m'>argument</a>))
             (<a id='632' tid='631' class='m'>while</a> (<a id='634' tid='633' class='m'>&gt;</a> <a id='636' tid='635' class='m'>argument</a> <a id='638' tid='637' class='m'>0</a>)
               (<a id='640' tid='639' class='m'>paredit-backward-delete</a>)
               (<a id='642' tid='641' class='m'>setq</a> <a id='644' tid='643' class='m'>argument</a> (<a id='646' tid='645' class='m'>-</a> <a id='648' tid='647' class='m'>argument</a> <a id='650' tid='649' class='m'>1</a>)))))
        <span class='i'>((paredit-in-string-p)
         (paredit-backward-delete-in-string))</span>
        <span class='i'>((paredit-in-comment-p)
         (paredit-backward-delete-in-comment))</span>
        ((<a id='484' tid='483' class='m'>paredit-in-char-p</a>)            <a id='486' tid='485' class='m'>; Escape -- delete both chars.
</a>         (<a id='488' tid='487' class='m'>backward-delete-char</a> <a id='490' tid='489' class='m'>1</a>)
         (<a id='492' tid='491' class='m'>delete-char</a> <a id='494' tid='493' class='m'>1</a>))
        ((<a id='450' tid='449' class='m'>paredit-in-char-p</a> (<a id='452' tid='451' class='m'>1-</a> (<a id='454' tid='453' class='m'>point</a>)))
         (<a id='456' tid='455' class='m'>backward-delete-char</a> <a id='458' tid='457' class='m'>2</a>))      <span class='i'>; ditto
</span>        ((<a id='380' tid='379' class='m'>let</a> ((<a id='382' tid='381' class='m'>syn</a> (<a id='384' tid='383' class='m'>char-syntax</a> (<a id='386' tid='385' class='m'>char-before</a>))))
           (<a id='388' tid='387' class='m'>or</a> (<a id='390' tid='389' class='m'>eq</a> <a id='392' tid='391' class='m'>syn</a> <a id='394' tid='393' class='m'>?\)</a> )
               (<a id='396' tid='395' class='m'>eq</a> <a id='398' tid='397' class='m'>syn</a> <a id='400' tid='399' class='m'>?\&quot;</a> )))
         (<a id='402' tid='401' class='m'>if</a> (<a id='404' tid='403' class='m'>save-excursion</a>
               (<a id='406' tid='405' class='m'>paredit-handle-sexp-errors</a> (<a id='408' tid='407' class='m'>progn</a> (<a id='410' tid='409' class='m'>backward-sexp</a>) <a id='412' tid='411' class='m'>t</a>)
                 <a id='414' tid='413' class='m'>nil</a>))
             (<a id='416' tid='415' class='m'>backward-char</a>)
           (<a id='418' tid='417' class='m'>message</a> <a id='420' tid='419' class='m'>&quot;Deleting spurious closing delimiter.&quot;</a>)
           (<a id='422' tid='421' class='m'>backward-delete-char</a> <a id='424' tid='423' class='m'>1</a>)))
        ((<a id='288' tid='287' class='m'>and</a> (<a id='290' tid='289' class='m'>eq</a> (<a id='292' tid='291' class='m'>char-syntax</a> (<a id='294' tid='293' class='m'>char-before</a>)) <a id='296' tid='295' class='m'>?\(</a> )
              (<a id='298' tid='297' class='m'>eq</a> (<a id='300' tid='299' class='m'>char-after</a>) (<a id='302' tid='301' class='m'>matching-paren</a> (<a id='304' tid='303' class='m'>char-before</a>))))
         (<a id='306' tid='305' class='m'>backward-delete-char</a> <a id='308' tid='307' class='m'>1</a>)       <a id='310' tid='309' class='m'>; Empty list -- delete both
</a>         (<a id='312' tid='311' class='m'>delete-char</a> <a id='314' tid='313' class='m'>1</a>))               <span class='i'>;   delimiters.
</span>        <span class='i'>((bolp)
         (paredit-backward-delete-maybe-comment-end))</span>
        <span class='i'>;; Delete it, unless it&#39;s an opening delimiter.  The case of
</span>        <span class='i'>;; character literals is already handled by now.
</span>        ((<a id='212' tid='211' class='m'>not</a> (<a id='214' tid='213' class='m'>eq</a> (<a id='216' tid='215' class='m'>char-syntax</a> (<a id='218' tid='217' class='m'>char-before</a>)) <a id='220' tid='219' class='m'>?\(</a> ))
         (<a id='222' tid='221' class='m'>backward-delete-char-untabify</a> <a id='224' tid='223' class='m'>1</a>))))

(<a id='2122' tid='2121' class='u'>defun</a> <a id='2124' tid='2123' class='u'>paredit-backward-delete-in-string</a> ()
  (<a id='2126' tid='2125' class='u'>let</a> ((<a id='2128' tid='2127' class='u'>start+end</a> (<a id='2130' tid='2129' class='u'>paredit-string-start+end-points</a>)))
    (<a id='2132' tid='2131' class='u'>cond</a> ((<a id='2134' tid='2133' class='u'>not</a> (<a id='2136' tid='2135' class='u'>eq</a> (<a id='2138' tid='2137' class='u'>1-</a> (<a id='2140' tid='2139' class='u'>point</a>)) (<a id='2142' tid='2141' class='u'>car</a> <a id='2144' tid='2143' class='u'>start+end</a>)))
           <a id='2146' tid='2145' class='u'>;; If it&#39;s not the open-quote, it&#39;s safe to delete.
</a>           (<a id='2148' tid='2147' class='u'>if</a> (<a id='2150' tid='2149' class='u'>paredit-in-string-escape-p</a>)
               <a id='2152' tid='2151' class='u'>;; If we&#39;re on a string escape, since we&#39;re about to
</a>               <a id='2154' tid='2153' class='u'>;; delete the backslash, we must first delete the
</a>               <a id='2156' tid='2155' class='u'>;; escaped char.
</a>               (<a id='2158' tid='2157' class='u'>delete-char</a> <a id='2160' tid='2159' class='u'>1</a>))
           (<a id='2162' tid='2161' class='u'>backward-delete-char</a> <a id='2164' tid='2163' class='u'>1</a>)
           (<a id='2166' tid='2165' class='u'>if</a> (<a id='2168' tid='2167' class='u'>paredit-in-string-escape-p</a>)
               <a id='2170' tid='2169' class='u'>;; If, after deleting a character, we find ourselves in
</a>               <a id='2172' tid='2171' class='u'>;; a string escape, we must have deleted the escaped
</a>               <a id='2174' tid='2173' class='u'>;; character, and the backslash is behind the point, so
</a>               <a id='2176' tid='2175' class='u'>;; backward delete it.
</a>               (<a id='2178' tid='2177' class='u'>backward-delete-char</a> <a id='2180' tid='2179' class='u'>1</a>)))
          ((<a id='2182' tid='2181' class='u'>eq</a> (<a id='2184' tid='2183' class='u'>point</a>) (<a id='2186' tid='2185' class='u'>cdr</a> <a id='2188' tid='2187' class='u'>start+end</a>))
           <a id='2190' tid='2189' class='u'>;; If it is the open-quote, delete only if we&#39;re also right
</a>           <a id='2192' tid='2191' class='u'>;; past the close-quote (i.e. it&#39;s empty), and then delete
</a>           <a id='2194' tid='2193' class='u'>;; both quotes.  Otherwise we refuse to delete it.
</a>           (<a id='2196' tid='2195' class='u'>backward-delete-char</a> <a id='2198' tid='2197' class='u'>1</a>)
           (<a id='2200' tid='2199' class='u'>delete-char</a> <a id='2202' tid='2201' class='u'>1</a>)))))

<span class='i'>(defun paredit-backward-delete-in-comment ()
  ;; Point is in a comment, possibly just after the comment start.
  ;; Refuse to delete a comment start if the comment contains
  ;; unbalanced junk.
  (if (save-excursion
        (backward-char)
        ;; Must call `paredit-in-string-p&#39; before
        ;; `paredit-in-comment-p&#39;.
        (not (or (paredit-in-string-p) (paredit-in-comment-p))))
      (paredit-check-region (point) (point-at-eol)))
  (backward-delete-char-untabify +1))</span>

<span class='i'>(defun paredit-backward-delete-maybe-comment-end ()
  ;; Point is at bol, possibly just after a comment end (i.e., the
  ;; previous line may have had a line comment).  Refuse to delete a
  ;; comment end if moving the current line into the previous line&#39;s
  ;; comment would break structure.
  (if (save-excursion
        (backward-char)
        (and (not (paredit-in-string-p)) (paredit-in-comment-p)))
      (paredit-check-region (point-at-eol) (point-at-bol)))
  (backward-delete-char 1))</span>

<a id='7346' tid='7345' class='u'>;;;; Killing
</a>
(<a id='4552' tid='4551' class='u'>defun</a> <a id='4554' tid='4553' class='u'>paredit-kill</a> (<a id='4556' tid='4555' class='u'>&optional</a> <a id='4558' tid='4557' class='u'>argument</a>)
  <a id='4560' tid='4559' class='u'>&quot;Kill a line as if with `kill-line&#39;, but respecting delimiters.
In a string, act exactly as `kill-line&#39; but do not kill past the
  closing string delimiter.
On a line with no S-expressions on it starting after the point or
  within a comment, act exactly as `kill-line&#39;.
Otherwise, kill all S-expressions that start after the point.
With a `C-u&#39; prefix argument, just do the standard `kill-line&#39;.
With a numeric prefix argument N, do `kill-line&#39; that many times.&quot;</a>
  (<a id='4562' tid='4561' class='u'>interactive</a> <a id='4564' tid='4563' class='u'>&quot;P&quot;</a>)
  (<span class='i'>cond</span> (<a id='1264' tid='1263' class='m'>argument</a>
         (<a id='1266' tid='1265' class='m'>kill-line</a> (<a id='1268' tid='1267' class='m'>if</a> (<a id='1270' tid='1269' class='m'>integerp</a> <a id='1272' tid='1271' class='m'>argument</a>) <a id='1274' tid='1273' class='m'>argument</a> <a id='1276' tid='1275' class='m'>1</a>)))
        <span class='i'>((paredit-in-string-p)
         (paredit-kill-line-in-string))</span>
        <span class='i'>((paredit-in-comment-p)
         (paredit-kill-line-in-comment))</span>
        ((<a id='652' tid='651' class='m'>save-excursion</a> (<a id='654' tid='653' class='m'>paredit-skip-whitespace</a> <a id='656' tid='655' class='m'>t</a> (<a id='658' tid='657' class='m'>point-at-eol</a>))
                         (<a id='660' tid='659' class='m'>or</a> (<a id='662' tid='661' class='m'>eolp</a>) (<a id='664' tid='663' class='m'>eq</a> (<a id='666' tid='665' class='m'>char-after</a>) <a id='668' tid='667' class='m'>?\;</a> )))
         <a id='670' tid='669' class='m'>;** Be careful about trailing backslashes.
</a>         (<a id='672' tid='671' class='m'>if</a> (<a id='674' tid='673' class='m'>paredit-in-char-p</a>)
             (<a id='676' tid='675' class='m'>backward-char</a>))
         (<a id='678' tid='677' class='m'>kill-line</a>))
        <span class='i'>(t (paredit-kill-sexps-on-line))</span>))

(<a id='4566' tid='4565' class='u'>defun</a> <a id='4568' tid='4567' class='u'>paredit-kill-line-in-string</a> ()
  (<a id='4570' tid='4569' class='u'>if</a> (<a id='4572' tid='4571' class='u'>save-excursion</a> (<a id='4574' tid='4573' class='u'>paredit-skip-whitespace</a> <a id='4576' tid='4575' class='u'>t</a> (<a id='4578' tid='4577' class='u'>point-at-eol</a>))
                      (<a id='4580' tid='4579' class='u'>eolp</a>))
      (<a id='4582' tid='4581' class='u'>kill-line</a>)
    (<a id='4584' tid='4583' class='u'>save-excursion</a>
      <a id='4586' tid='4585' class='u'>;; Be careful not to split an escape sequence.
</a>      (<a id='4588' tid='4587' class='u'>if</a> (<a id='4590' tid='4589' class='u'>paredit-in-string-escape-p</a>)
          (<a id='4592' tid='4591' class='u'>backward-char</a>))
      (<a id='4594' tid='4593' class='u'>kill-region</a> (<a id='4596' tid='4595' class='u'>point</a>)
                   (<a id='4598' tid='4597' class='u'>min</a> (<a id='4600' tid='4599' class='u'>point-at-eol</a>)
                        (<a id='4602' tid='4601' class='u'>cdr</a> (<a id='4604' tid='4603' class='u'>paredit-string-start+end-points</a>)))))))

<span class='i'>(defun paredit-kill-line-in-comment ()
  ;; If we&#39;re at the end of line, this is the same as deleting the line
  ;; end, which `paredit-forward-delete-in-comment&#39; handles carefully.
  ;; The variable `kill-whole-line&#39; is not relevant: the point is in a
  ;; comment, and hence not at the beginning of the line.
  (if (eolp)
      (paredit-forward-delete-in-comment)
      (kill-line)))</span>

(<a id='4622' tid='4621' class='u'>defun</a> <a id='4624' tid='4623' class='u'>paredit-kill-sexps-on-line</a> ()
  (<a id='4626' tid='4625' class='u'>if</a> (<a id='4628' tid='4627' class='u'>paredit-in-char-p</a>)               <a id='4630' tid='4629' class='u'>; Move past the \ and prefix.
</a>      (<a id='4632' tid='4631' class='u'>backward-char</a> <a id='4634' tid='4633' class='u'>2</a>))                <a id='4636' tid='4635' class='u'>; (# in Scheme/CL, ? in elisp)
</a>  (<a id='4638' tid='4637' class='u'>let</a> ((<a id='4640' tid='4639' class='u'>beginning</a> (<a id='4642' tid='4641' class='u'>point</a>))
        (<a id='4644' tid='4643' class='u'>eol</a> (<a id='4646' tid='4645' class='u'>point-at-eol</a>)))
    (<a id='4648' tid='4647' class='u'>let</a> ((<a id='4650' tid='4649' class='u'>end-of-list-p</a> (<a id='4652' tid='4651' class='u'>paredit-forward-sexps-to-kill</a> <a id='4654' tid='4653' class='u'>beginning</a> <a id='4656' tid='4655' class='u'>eol</a>)))
      <a id='4658' tid='4657' class='u'>;; If we got to the end of the list and it&#39;s on the same line,
</a>      <a id='4660' tid='4659' class='u'>;; move backward past the closing delimiter before killing.  (This
</a>      <a id='4662' tid='4661' class='u'>;; allows something like killing the whitespace in (    ).)
</a>      (<a id='4664' tid='4663' class='u'>if</a> <a id='4666' tid='4665' class='u'>end-of-list-p</a> (<a id='4668' tid='4667' class='u'>progn</a> (<a id='4670' tid='4669' class='u'>up-list</a>) (<a id='4672' tid='4671' class='u'>backward-char</a>)))
      (<a id='4674' tid='4673' class='u'>if</a> <a id='4676' tid='4675' class='u'>kill-whole-line</a>
          (<a id='4678' tid='4677' class='u'>paredit-kill-sexps-on-whole-line</a> <a id='4680' tid='4679' class='u'>beginning</a>)
        (<a id='4682' tid='4681' class='u'>kill-region</a> <a id='4684' tid='4683' class='u'>beginning</a>
                     <a id='4686' tid='4685' class='u'>;; If all of the S-expressions were on one line,
</a>                     <a id='4688' tid='4687' class='u'>;; i.e. we&#39;re still on that line after moving past
</a>                     <a id='4690' tid='4689' class='u'>;; the last one, kill the whole line, including
</a>                     <a id='4692' tid='4691' class='u'>;; any comments; otherwise just kill to the end of
</a>                     <a id='4694' tid='4693' class='u'>;; the last S-expression we found.  Be sure,
</a>                     <a id='4696' tid='4695' class='u'>;; though, not to kill any closing parentheses.
</a>                     (<a id='4698' tid='4697' class='u'>if</a> (<a id='4700' tid='4699' class='u'>and</a> (<a id='4702' tid='4701' class='u'>not</a> <a id='4704' tid='4703' class='u'>end-of-list-p</a>)
                              (<a id='4706' tid='4705' class='u'>eq</a> (<a id='4708' tid='4707' class='u'>point-at-eol</a>) <a id='4710' tid='4709' class='u'>eol</a>))
                         <a id='4712' tid='4711' class='u'>eol</a>
                         (<a id='4714' tid='4713' class='u'>point</a>)))))))

<a id='7348' tid='7347' class='u'>;;; Please do not try to understand this code unless you have a VERY
</a><a id='7350' tid='7349' class='u'>;;; good reason to do so.  I gave up trying to figure it out well
</a><a id='7352' tid='7351' class='u'>;;; enough to explain it, long ago.
</a>
(<a id='3648' tid='3647' class='u'>defun</a> <a id='3650' tid='3649' class='u'>paredit-forward-sexps-to-kill</a> (<a id='3652' tid='3651' class='u'>beginning</a> <a id='3654' tid='3653' class='u'>eol</a>)
  (<a id='3656' tid='3655' class='u'>let</a> ((<a id='3658' tid='3657' class='u'>end-of-list-p</a> <a id='3660' tid='3659' class='u'>nil</a>)
        (<a id='3662' tid='3661' class='u'>firstp</a> <a id='3664' tid='3663' class='u'>t</a>))
    <a id='3666' tid='3665' class='u'>;; Move to the end of the last S-expression that started on this
</a>    <a id='3668' tid='3667' class='u'>;; line, or to the closing delimiter if the last S-expression in
</a>    <a id='3670' tid='3669' class='u'>;; this list is on the line.
</a>    (<a id='3672' tid='3671' class='u'>catch</a> <a id='3674' tid='3673' class='u'>&#39;</a><a id='3676' tid='3675' class='u'>return</a>
      (<a id='3678' tid='3677' class='u'>while</a> <a id='3680' tid='3679' class='u'>t</a>
        <a id='3682' tid='3681' class='u'>;; This and the `kill-whole-line&#39; business below fix a bug that
</a>        <a id='3684' tid='3683' class='u'>;; inhibited any S-expression at the very end of the buffer
</a>        <a id='3686' tid='3685' class='u'>;; (with no trailing newline) from being deleted.  It&#39;s a
</a>        <a id='3688' tid='3687' class='u'>;; bizarre fix that I ought to document at some point, but I am
</a>        <a id='3690' tid='3689' class='u'>;; too busy at the moment to do so.
</a>        (<a id='3692' tid='3691' class='u'>if</a> (<a id='3694' tid='3693' class='u'>and</a> <a id='3696' tid='3695' class='u'>kill-whole-line</a> (<a id='3698' tid='3697' class='u'>eobp</a>)) (<a id='3700' tid='3699' class='u'>throw</a> <a id='3702' tid='3701' class='u'>&#39;</a><a id='3704' tid='3703' class='u'>return</a> <a id='3706' tid='3705' class='u'>nil</a>))
        (<a id='3708' tid='3707' class='u'>save-excursion</a>
          (<a id='3710' tid='3709' class='u'>paredit-handle-sexp-errors</a> (<a id='3712' tid='3711' class='u'>forward-sexp</a>)
            (<a id='3714' tid='3713' class='u'>up-list</a>)
            (<a id='3716' tid='3715' class='u'>setq</a> <a id='3718' tid='3717' class='u'>end-of-list-p</a> (<a id='3720' tid='3719' class='u'>eq</a> (<a id='3722' tid='3721' class='u'>point-at-eol</a>) <a id='3724' tid='3723' class='u'>eol</a>))
            (<a id='3726' tid='3725' class='u'>throw</a> <a id='3728' tid='3727' class='u'>&#39;</a><a id='3730' tid='3729' class='u'>return</a> <a id='3732' tid='3731' class='u'>nil</a>))
          (<a id='3734' tid='3733' class='u'>if</a> (<a id='3736' tid='3735' class='u'>or</a> (<a id='3738' tid='3737' class='u'>and</a> (<a id='3740' tid='3739' class='u'>not</a> <a id='3742' tid='3741' class='u'>firstp</a>)
                       (<a id='3744' tid='3743' class='u'>not</a> <a id='3746' tid='3745' class='u'>kill-whole-line</a>)
                       (<a id='3748' tid='3747' class='u'>eobp</a>))
                  (<a id='3750' tid='3749' class='u'>paredit-handle-sexp-errors</a>
                      (<a id='3752' tid='3751' class='u'>progn</a> (<a id='3754' tid='3753' class='u'>backward-sexp</a>) <a id='3756' tid='3755' class='u'>nil</a>)
                    <a id='3758' tid='3757' class='u'>t</a>)
                  (<a id='3760' tid='3759' class='u'>not</a> (<a id='3762' tid='3761' class='u'>eq</a> (<a id='3764' tid='3763' class='u'>point-at-eol</a>) <a id='3766' tid='3765' class='u'>eol</a>)))
              (<a id='3768' tid='3767' class='u'>throw</a> <a id='3770' tid='3769' class='u'>&#39;</a><a id='3772' tid='3771' class='u'>return</a> <a id='3774' tid='3773' class='u'>nil</a>)))
        (<a id='3776' tid='3775' class='u'>forward-sexp</a>)
        (<a id='3778' tid='3777' class='u'>if</a> (<a id='3780' tid='3779' class='u'>and</a> <a id='3782' tid='3781' class='u'>firstp</a>
                 (<a id='3784' tid='3783' class='u'>not</a> <a id='3786' tid='3785' class='u'>kill-whole-line</a>)
                 (<a id='3788' tid='3787' class='u'>eobp</a>))
            (<a id='3790' tid='3789' class='u'>throw</a> <a id='3792' tid='3791' class='u'>&#39;</a><a id='3794' tid='3793' class='u'>return</a> <a id='3796' tid='3795' class='u'>nil</a>))
        (<a id='3798' tid='3797' class='u'>setq</a> <a id='3800' tid='3799' class='u'>firstp</a> <a id='3802' tid='3801' class='u'>nil</a>)))
    <a id='3804' tid='3803' class='u'>end-of-list-p</a>))

(<a id='4716' tid='4715' class='u'>defun</a> <a id='4718' tid='4717' class='u'>paredit-kill-sexps-on-whole-line</a> (<a id='4720' tid='4719' class='u'>beginning</a>)
  (<a id='4722' tid='4721' class='u'>kill-region</a> <a id='4724' tid='4723' class='u'>beginning</a>
               (<a id='4726' tid='4725' class='u'>or</a> (<a id='4728' tid='4727' class='u'>save-excursion</a>     <a id='4730' tid='4729' class='u'>; Delete trailing indentation...
</a>                     (<a id='4732' tid='4731' class='u'>paredit-skip-whitespace</a> <a id='4734' tid='4733' class='u'>t</a>)
                     (<a id='4736' tid='4735' class='u'>and</a> (<a id='4738' tid='4737' class='u'>not</a> (<a id='4740' tid='4739' class='u'>eq</a> (<a id='4742' tid='4741' class='u'>char-after</a>) <a id='4744' tid='4743' class='u'>?\;</a> ))
                          (<a id='4746' tid='4745' class='u'>point</a>)))
                   <a id='4748' tid='4747' class='u'>;; ...or just use the point past the newline, if
</a>                   <a id='4750' tid='4749' class='u'>;; we encounter a comment.
</a>                   (<a id='4752' tid='4751' class='u'>point-at-eol</a>)))
  (<a id='4754' tid='4753' class='u'>cond</a> ((<a id='4756' tid='4755' class='u'>save-excursion</a> (<a id='4758' tid='4757' class='u'>paredit-skip-whitespace</a> <a id='4760' tid='4759' class='u'>nil</a> (<a id='4762' tid='4761' class='u'>point-at-bol</a>))
                         (<a id='4764' tid='4763' class='u'>bolp</a>))
         <a id='4766' tid='4765' class='u'>;; Nothing but indentation before the point, so indent it.
</a>         (<a id='4768' tid='4767' class='u'>lisp-indent-line</a>))
        ((<a id='4770' tid='4769' class='u'>eobp</a>) <a id='4772' tid='4771' class='u'>nil</a>)       <a id='4774' tid='4773' class='u'>; Protect the CHAR-SYNTAX below against NIL.
</a>        <a id='4776' tid='4775' class='u'>;; Insert a space to avoid invalid joining if necessary.
</a>        ((<a id='4778' tid='4777' class='u'>let</a> ((<a id='4780' tid='4779' class='u'>syn-before</a> (<a id='4782' tid='4781' class='u'>char-syntax</a> (<a id='4784' tid='4783' class='u'>char-before</a>)))
               (<a id='4786' tid='4785' class='u'>syn-after</a>  (<a id='4788' tid='4787' class='u'>char-syntax</a> (<a id='4790' tid='4789' class='u'>char-after</a>))))
           (<a id='4792' tid='4791' class='u'>or</a> (<a id='4794' tid='4793' class='u'>and</a> (<a id='4796' tid='4795' class='u'>eq</a> <a id='4798' tid='4797' class='u'>syn-before</a> <a id='4800' tid='4799' class='u'>?\)</a> )            <a id='4802' tid='4801' class='u'>; Separate opposing
</a>                    (<a id='4804' tid='4803' class='u'>eq</a> <a id='4806' tid='4805' class='u'>syn-after</a>  <a id='4808' tid='4807' class='u'>?\(</a> ))           <a id='4810' tid='4809' class='u'>;   parentheses,
</a>               (<a id='4812' tid='4811' class='u'>and</a> (<a id='4814' tid='4813' class='u'>eq</a> <a id='4816' tid='4815' class='u'>syn-before</a> <a id='4818' tid='4817' class='u'>?\&quot;</a> )            <a id='4820' tid='4819' class='u'>; string delimiter
</a>                    (<a id='4822' tid='4821' class='u'>eq</a> <a id='4824' tid='4823' class='u'>syn-after</a>  <a id='4826' tid='4825' class='u'>?\&quot;</a> ))           <a id='4828' tid='4827' class='u'>;   pairs,
</a>               (<a id='4830' tid='4829' class='u'>and</a> (<a id='4832' tid='4831' class='u'>memq</a> <a id='4834' tid='4833' class='u'>syn-before</a> <a id='4836' tid='4835' class='u'>&#39;</a>(<a id='4838' tid='4837' class='u'>?_</a> <a id='4840' tid='4839' class='u'>?w</a>))      <a id='4842' tid='4841' class='u'>; or word or symbol
</a>                    (<a id='4844' tid='4843' class='u'>memq</a> <a id='4846' tid='4845' class='u'>syn-after</a>  <a id='4848' tid='4847' class='u'>&#39;</a>(<a id='4850' tid='4849' class='u'>?_</a> <a id='4852' tid='4851' class='u'>?w</a>)))))   <a id='4854' tid='4853' class='u'>;   constituents.
</a>         (<a id='4856' tid='4855' class='u'>insert</a> <a id='4858' tid='4857' class='u'>&quot; &quot;</a>))))

<a id='7354' tid='7353' class='u'>;;;;; Killing Words
</a>
<a id='7356' tid='7355' class='u'>;;; This is tricky and asymmetrical because backward parsing is
</a><a id='7358' tid='7357' class='u'>;;; extraordinarily difficult or impossible, so we have to implement
</a><a id='7360' tid='7359' class='u'>;;; killing in both directions by parsing forward.
</a>
(<a id='3518' tid='3517' class='u'>defun</a> <a id='3520' tid='3519' class='u'>paredit-forward-kill-word</a> ()
  <a id='3522' tid='3521' class='u'>&quot;Kill a word forward, skipping over intervening delimiters.&quot;</a>
  (<a id='3524' tid='3523' class='u'>interactive</a>)
  (<a id='3526' tid='3525' class='u'>let</a> ((<a id='3528' tid='3527' class='u'>beginning</a> (<a id='3530' tid='3529' class='u'>point</a>)))
    (<a id='3532' tid='3531' class='u'>skip-syntax-forward</a> <a id='3534' tid='3533' class='u'>&quot; -&quot;</a>)
    (<a id='3536' tid='3535' class='u'>let*</a> ((<a id='3538' tid='3537' class='u'>parse-state</a> (<a id='3540' tid='3539' class='u'>paredit-current-parse-state</a>))
           (<a id='3542' tid='3541' class='u'>state</a> (<a id='3544' tid='3543' class='u'>paredit-kill-word-state</a> <a id='3546' tid='3545' class='u'>parse-state</a> <a id='3548' tid='3547' class='u'>&#39;</a><a id='3550' tid='3549' class='u'>char-after</a>)))
      (<a id='3552' tid='3551' class='u'>while</a> (<a id='3554' tid='3553' class='u'>not</a> (<a id='3556' tid='3555' class='u'>or</a> (<a id='3558' tid='3557' class='u'>eobp</a>)
                      (<a id='3560' tid='3559' class='u'>eq</a> <a id='3562' tid='3561' class='u'>?w</a> (<a id='3564' tid='3563' class='u'>char-syntax</a> (<a id='3566' tid='3565' class='u'>char-after</a>)))))
        (<a id='3568' tid='3567' class='u'>setq</a> <a id='3570' tid='3569' class='u'>parse-state</a>
              (<a id='3572' tid='3571' class='u'>progn</a> (<a id='3574' tid='3573' class='u'>forward-char</a> <a id='3576' tid='3575' class='u'>1</a>) (<a id='3578' tid='3577' class='u'>paredit-current-parse-state</a>))
<a id='3580' tid='3579' class='u'>;;               (parse-partial-sexp (point) (1+ (point))
</a><a id='3582' tid='3581' class='u'>;;                                   nil nil parse-state)
</a>              )
        (<a id='3584' tid='3583' class='u'>let*</a> ((<a id='3586' tid='3585' class='u'>old-state</a> <a id='3588' tid='3587' class='u'>state</a>)
               (<a id='3590' tid='3589' class='u'>new-state</a>
                (<a id='3592' tid='3591' class='u'>paredit-kill-word-state</a> <a id='3594' tid='3593' class='u'>parse-state</a> <a id='3596' tid='3595' class='u'>&#39;</a><a id='3598' tid='3597' class='u'>char-after</a>)))
          (<a id='3600' tid='3599' class='u'>cond</a> ((<a id='3602' tid='3601' class='u'>not</a> (<a id='3604' tid='3603' class='u'>eq</a> <a id='3606' tid='3605' class='u'>old-state</a> <a id='3608' tid='3607' class='u'>new-state</a>))
                 (<a id='3610' tid='3609' class='u'>setq</a> <a id='3612' tid='3611' class='u'>parse-state</a>
                       (<a id='3614' tid='3613' class='u'>paredit-kill-word-hack</a> <a id='3616' tid='3615' class='u'>old-state</a>
                                               <a id='3618' tid='3617' class='u'>new-state</a>
                                               <a id='3620' tid='3619' class='u'>parse-state</a>))
                 (<a id='3622' tid='3621' class='u'>setq</a> <a id='3624' tid='3623' class='u'>state</a>
                       (<a id='3626' tid='3625' class='u'>paredit-kill-word-state</a> <a id='3628' tid='3627' class='u'>parse-state</a>
                                                <a id='3630' tid='3629' class='u'>&#39;</a><a id='3632' tid='3631' class='u'>char-after</a>))
                 (<a id='3634' tid='3633' class='u'>setq</a> <a id='3636' tid='3635' class='u'>beginning</a> (<a id='3638' tid='3637' class='u'>point</a>)))))))
    (<a id='3640' tid='3639' class='u'>goto-char</a> <a id='3642' tid='3641' class='u'>beginning</a>)
    (<a id='3644' tid='3643' class='u'>kill-word</a> <a id='3646' tid='3645' class='u'>1</a>)))

(<a id='2246' tid='2245' class='u'>defun</a> <a id='2248' tid='2247' class='u'>paredit-backward-kill-word</a> ()
  <a id='2250' tid='2249' class='u'>&quot;Kill a word backward, skipping over any intervening delimiters.&quot;</a>
  (<a id='2252' tid='2251' class='u'>interactive</a>)
  (<a id='2254' tid='2253' class='u'>if</a> (<a id='2256' tid='2255' class='u'>not</a> (<a id='2258' tid='2257' class='u'>or</a> (<a id='2260' tid='2259' class='u'>bobp</a>)
               (<a id='2262' tid='2261' class='u'>eq</a> (<a id='2264' tid='2263' class='u'>char-syntax</a> (<a id='2266' tid='2265' class='u'>char-before</a>)) <a id='2268' tid='2267' class='u'>?w</a>)))
      (<a id='2270' tid='2269' class='u'>let</a> ((<a id='2272' tid='2271' class='u'>end</a> (<a id='2274' tid='2273' class='u'>point</a>)))
        (<a id='2276' tid='2275' class='u'>backward-word</a> <a id='2278' tid='2277' class='u'>1</a>)
        (<a id='2280' tid='2279' class='u'>forward-word</a> <a id='2282' tid='2281' class='u'>1</a>)
        (<a id='2284' tid='2283' class='u'>goto-char</a> (<a id='2286' tid='2285' class='u'>min</a> <a id='2288' tid='2287' class='u'>end</a> (<a id='2290' tid='2289' class='u'>point</a>)))
        (<a id='2292' tid='2291' class='u'>let*</a> ((<a id='2294' tid='2293' class='u'>parse-state</a> (<a id='2296' tid='2295' class='u'>paredit-current-parse-state</a>))
               (<a id='2298' tid='2297' class='u'>state</a>
                (<a id='2300' tid='2299' class='u'>paredit-kill-word-state</a> <a id='2302' tid='2301' class='u'>parse-state</a> <a id='2304' tid='2303' class='u'>&#39;</a><a id='2306' tid='2305' class='u'>char-before</a>)))
          (<a id='2308' tid='2307' class='u'>while</a> (<a id='2310' tid='2309' class='u'>and</a> (<a id='2312' tid='2311' class='u'>&lt;</a> (<a id='2314' tid='2313' class='u'>point</a>) <a id='2316' tid='2315' class='u'>end</a>)
                      (<a id='2318' tid='2317' class='u'>progn</a>
                        (<a id='2320' tid='2319' class='u'>setq</a> <a id='2322' tid='2321' class='u'>parse-state</a>
                              (<a id='2324' tid='2323' class='u'>parse-partial-sexp</a> (<a id='2326' tid='2325' class='u'>point</a>) (<a id='2328' tid='2327' class='u'>1+</a> (<a id='2330' tid='2329' class='u'>point</a>))
                                                  <a id='2332' tid='2331' class='u'>nil</a> <a id='2334' tid='2333' class='u'>nil</a> <a id='2336' tid='2335' class='u'>parse-state</a>))
                        (<a id='2338' tid='2337' class='u'>or</a> (<a id='2340' tid='2339' class='u'>eq</a> <a id='2342' tid='2341' class='u'>state</a>
                                (<a id='2344' tid='2343' class='u'>paredit-kill-word-state</a> <a id='2346' tid='2345' class='u'>parse-state</a>
                                                         <a id='2348' tid='2347' class='u'>&#39;</a><a id='2350' tid='2349' class='u'>char-before</a>))
                            (<a id='2352' tid='2351' class='u'>progn</a> (<a id='2354' tid='2353' class='u'>backward-char</a> <a id='2356' tid='2355' class='u'>1</a>) <a id='2358' tid='2357' class='u'>nil</a>)))))
          (<a id='2360' tid='2359' class='u'>if</a> (<a id='2362' tid='2361' class='u'>and</a> (<a id='2364' tid='2363' class='u'>eq</a> <a id='2366' tid='2365' class='u'>state</a> <a id='2368' tid='2367' class='u'>&#39;</a><a id='2370' tid='2369' class='u'>comment</a>)
                   (<a id='2372' tid='2371' class='u'>eq</a> <a id='2374' tid='2373' class='u'>?\#</a> (<a id='2376' tid='2375' class='u'>char-after</a> (<a id='2378' tid='2377' class='u'>point</a>)))
                   (<a id='2380' tid='2379' class='u'>eq</a> <a id='2382' tid='2381' class='u'>?\|</a> (<a id='2384' tid='2383' class='u'>char-before</a> (<a id='2386' tid='2385' class='u'>point</a>))))
              (<a id='2388' tid='2387' class='u'>backward-char</a> <a id='2390' tid='2389' class='u'>1</a>)))))
  (<a id='2392' tid='2391' class='u'>backward-kill-word</a> <a id='2394' tid='2393' class='u'>1</a>))

<a id='7362' tid='7361' class='u'>;;;;;; Word-Killing Auxiliaries
</a>
(<a id='5136' tid='5135' class='u'>defun</a> <a id='5138' tid='5137' class='u'>paredit-kill-word-state</a> (<a id='5140' tid='5139' class='u'>parse-state</a> <a id='5142' tid='5141' class='u'>adjacent-char-fn</a>)
  (<a id='5144' tid='5143' class='u'>cond</a> ((<a id='5146' tid='5145' class='u'>paredit-in-comment-p</a> <a id='5148' tid='5147' class='u'>parse-state</a>) <a id='5150' tid='5149' class='u'>&#39;</a><a id='5152' tid='5151' class='u'>comment</a>)
        ((<a id='5154' tid='5153' class='u'>paredit-in-string-p</a>  <a id='5156' tid='5155' class='u'>parse-state</a>) <a id='5158' tid='5157' class='u'>&#39;</a><a id='5160' tid='5159' class='u'>string</a>)
        ((<a id='5162' tid='5161' class='u'>memq</a> (<a id='5164' tid='5163' class='u'>char-syntax</a> (<a id='5166' tid='5165' class='u'>funcall</a> <a id='5168' tid='5167' class='u'>adjacent-char-fn</a>))
               <a id='5170' tid='5169' class='u'>&#39;</a>(<a id='5172' tid='5171' class='u'>?\(</a> <a id='5174' tid='5173' class='u'>?\)</a> ))
         <a id='5176' tid='5175' class='u'>&#39;</a><a id='5178' tid='5177' class='u'>delimiter</a>)
        (<a id='5180' tid='5179' class='u'>t</a> <a id='5182' tid='5181' class='u'>&#39;</a><a id='5184' tid='5183' class='u'>other</a>)))

<a id='7364' tid='7363' class='u'>;;; This optionally advances the point past any comment delimiters that
</a><a id='7366' tid='7365' class='u'>;;; should probably not be touched, based on the last state change and
</a><a id='7368' tid='7367' class='u'>;;; the characters around the point.  It returns a new parse state,
</a><a id='7370' tid='7369' class='u'>;;; starting from the PARSE-STATE parameter.
</a>
(<a id='5034' tid='5033' class='u'>defun</a> <a id='5036' tid='5035' class='u'>paredit-kill-word-hack</a> (<a id='5038' tid='5037' class='u'>old-state</a> <a id='5040' tid='5039' class='u'>new-state</a> <a id='5042' tid='5041' class='u'>parse-state</a>)
  (<a id='5044' tid='5043' class='u'>cond</a> ((<a id='5046' tid='5045' class='u'>and</a> (<a id='5048' tid='5047' class='u'>not</a> (<a id='5050' tid='5049' class='u'>eq</a> <a id='5052' tid='5051' class='u'>old-state</a> <a id='5054' tid='5053' class='u'>&#39;</a><a id='5056' tid='5055' class='u'>comment</a>))
              (<a id='5058' tid='5057' class='u'>not</a> (<a id='5060' tid='5059' class='u'>eq</a> <a id='5062' tid='5061' class='u'>new-state</a> <a id='5064' tid='5063' class='u'>&#39;</a><a id='5066' tid='5065' class='u'>comment</a>))
              (<a id='5068' tid='5067' class='u'>not</a> (<a id='5070' tid='5069' class='u'>paredit-in-string-escape-p</a>))
              (<a id='5072' tid='5071' class='u'>eq</a> <a id='5074' tid='5073' class='u'>?\#</a> (<a id='5076' tid='5075' class='u'>char-before</a>))
              (<a id='5078' tid='5077' class='u'>eq</a> <a id='5080' tid='5079' class='u'>?\|</a> (<a id='5082' tid='5081' class='u'>char-after</a>)))
         (<a id='5084' tid='5083' class='u'>forward-char</a> <a id='5086' tid='5085' class='u'>1</a>)
         (<a id='5088' tid='5087' class='u'>paredit-current-parse-state</a>)
<a id='5090' tid='5089' class='u'>;;          (parse-partial-sexp (point) (1+ (point))
</a><a id='5092' tid='5091' class='u'>;;                              nil nil parse-state)
</a>         )
        ((<a id='5094' tid='5093' class='u'>and</a> (<a id='5096' tid='5095' class='u'>not</a> (<a id='5098' tid='5097' class='u'>eq</a> <a id='5100' tid='5099' class='u'>old-state</a> <a id='5102' tid='5101' class='u'>&#39;</a><a id='5104' tid='5103' class='u'>comment</a>))
              (<a id='5106' tid='5105' class='u'>eq</a> <a id='5108' tid='5107' class='u'>new-state</a> <a id='5110' tid='5109' class='u'>&#39;</a><a id='5112' tid='5111' class='u'>comment</a>)
              (<a id='5114' tid='5113' class='u'>eq</a> <a id='5116' tid='5115' class='u'>?\;</a> (<a id='5118' tid='5117' class='u'>char-before</a>)))
         (<a id='5120' tid='5119' class='u'>skip-chars-forward</a> <a id='5122' tid='5121' class='u'>&quot;;&quot;</a>)
         (<a id='5124' tid='5123' class='u'>paredit-current-parse-state</a>)
<a id='5126' tid='5125' class='u'>;;          (parse-partial-sexp (point) (save-excursion
</a><a id='5128' tid='5127' class='u'>;;                                        (skip-chars-forward &quot;;&quot;))
</a><a id='5130' tid='5129' class='u'>;;                              nil nil parse-state)
</a>         )
        (<a id='5132' tid='5131' class='u'>t</a> <a id='5134' tid='5133' class='u'>parse-state</a>)))

(<a id='2752' tid='2751' class='u'>defun</a> <a id='2754' tid='2753' class='u'>paredit-copy-as-kill</a> ()
  <a id='2756' tid='2755' class='u'>&quot;Save in the kill ring the region that `paredit-kill&#39; would kill.&quot;</a>
  (<a id='2758' tid='2757' class='u'>interactive</a>)
  (<a id='2760' tid='2759' class='u'>cond</a> ((<a id='2762' tid='2761' class='u'>paredit-in-string-p</a>)
         (<a id='2764' tid='2763' class='u'>paredit-copy-as-kill-in-string</a>))
        ((<a id='2766' tid='2765' class='u'>paredit-in-comment-p</a>)
         (<a id='2768' tid='2767' class='u'>copy-region-as-kill</a> (<a id='2770' tid='2769' class='u'>point</a>) (<a id='2772' tid='2771' class='u'>point-at-eol</a>)))
        ((<a id='2774' tid='2773' class='u'>save-excursion</a> (<a id='2776' tid='2775' class='u'>paredit-skip-whitespace</a> <a id='2778' tid='2777' class='u'>t</a> (<a id='2780' tid='2779' class='u'>point-at-eol</a>))
                         (<a id='2782' tid='2781' class='u'>or</a> (<a id='2784' tid='2783' class='u'>eolp</a>) (<a id='2786' tid='2785' class='u'>eq</a> (<a id='2788' tid='2787' class='u'>char-after</a>) <a id='2790' tid='2789' class='u'>?\;</a> )))
         <a id='2792' tid='2791' class='u'>;** Be careful about trailing backslashes.
</a>         (<a id='2794' tid='2793' class='u'>save-excursion</a>
           (<a id='2796' tid='2795' class='u'>if</a> (<a id='2798' tid='2797' class='u'>paredit-in-char-p</a>)
               (<a id='2800' tid='2799' class='u'>backward-char</a>))
           (<a id='2802' tid='2801' class='u'>copy-region-as-kill</a> (<a id='2804' tid='2803' class='u'>point</a>) (<a id='2806' tid='2805' class='u'>point-at-eol</a>))))
        (<a id='2808' tid='2807' class='u'>t</a> (<a id='2810' tid='2809' class='u'>paredit-copy-sexps-as-kill</a>))))

(<a id='2812' tid='2811' class='u'>defun</a> <a id='2814' tid='2813' class='u'>paredit-copy-as-kill-in-string</a> ()
  (<a id='2816' tid='2815' class='u'>save-excursion</a>
    (<a id='2818' tid='2817' class='u'>if</a> (<a id='2820' tid='2819' class='u'>paredit-in-string-escape-p</a>)
        (<a id='2822' tid='2821' class='u'>backward-char</a>))
    (<a id='2824' tid='2823' class='u'>copy-region-as-kill</a> (<a id='2826' tid='2825' class='u'>point</a>)
                         (<a id='2828' tid='2827' class='u'>min</a> (<a id='2830' tid='2829' class='u'>point-at-eol</a>)
                              (<a id='2832' tid='2831' class='u'>cdr</a> (<a id='2834' tid='2833' class='u'>paredit-string-start+end-points</a>))))))

(<a id='2836' tid='2835' class='u'>defun</a> <a id='2838' tid='2837' class='u'>paredit-copy-sexps-as-kill</a> ()
  (<a id='2840' tid='2839' class='u'>save-excursion</a>
    (<a id='2842' tid='2841' class='u'>if</a> (<a id='2844' tid='2843' class='u'>paredit-in-char-p</a>)
        (<a id='2846' tid='2845' class='u'>backward-char</a> <a id='2848' tid='2847' class='u'>2</a>))
    (<a id='2850' tid='2849' class='u'>let</a> ((<a id='2852' tid='2851' class='u'>beginning</a> (<a id='2854' tid='2853' class='u'>point</a>))
          (<a id='2856' tid='2855' class='u'>eol</a> (<a id='2858' tid='2857' class='u'>point-at-eol</a>)))
      (<a id='2860' tid='2859' class='u'>let</a> ((<a id='2862' tid='2861' class='u'>end-of-list-p</a> (<a id='2864' tid='2863' class='u'>paredit-forward-sexps-to-kill</a> <a id='2866' tid='2865' class='u'>beginning</a> <a id='2868' tid='2867' class='u'>eol</a>)))
        (<a id='2870' tid='2869' class='u'>if</a> <a id='2872' tid='2871' class='u'>end-of-list-p</a> (<a id='2874' tid='2873' class='u'>progn</a> (<a id='2876' tid='2875' class='u'>up-list</a>) (<a id='2878' tid='2877' class='u'>backward-char</a>)))
        (<a id='2880' tid='2879' class='u'>copy-region-as-kill</a> <a id='2882' tid='2881' class='u'>beginning</a>
                             (<a id='2884' tid='2883' class='u'>cond</a> (<a id='2886' tid='2885' class='u'>kill-whole-line</a>
                                    (<a id='2888' tid='2887' class='u'>or</a> (<a id='2890' tid='2889' class='u'>save-excursion</a>
                                          (<a id='2892' tid='2891' class='u'>paredit-skip-whitespace</a> <a id='2894' tid='2893' class='u'>t</a>)
                                          (<a id='2896' tid='2895' class='u'>and</a> (<a id='2898' tid='2897' class='u'>not</a> (<a id='2900' tid='2899' class='u'>eq</a> (<a id='2902' tid='2901' class='u'>char-after</a>) <a id='2904' tid='2903' class='u'>?\;</a> ))
                                               (<a id='2906' tid='2905' class='u'>point</a>)))
                                        (<a id='2908' tid='2907' class='u'>point-at-eol</a>)))
                                   ((<a id='2910' tid='2909' class='u'>and</a> (<a id='2912' tid='2911' class='u'>not</a> <a id='2914' tid='2913' class='u'>end-of-list-p</a>)
                                         (<a id='2916' tid='2915' class='u'>eq</a> (<a id='2918' tid='2917' class='u'>point-at-eol</a>) <a id='2920' tid='2919' class='u'>eol</a>))
                                    <a id='2922' tid='2921' class='u'>eol</a>)
                                   (<a id='2924' tid='2923' class='u'>t</a>
                                    (<a id='2926' tid='2925' class='u'>point</a>))))))))

<span class='i'>;;;; Deleting Regions
</span>
<span class='i'>(defun paredit-delete-region (start end)
  &quot;Delete the text between point and mark, like `delete-region&#39;.
If that text is unbalanced, signal an error instead.
With a prefix argument, skip the balance check.&quot;
  (interactive &quot;r&quot;)
  (if (and start end (not current-prefix-arg))
      (paredit-check-region-for-delete start end))
  (setq this-command &#39;delete-region)
  (delete-region start end))</span>

(<a id='4606' tid='4605' class='u'>defun</a> <a id='4608' tid='4607' class='u'>paredit-kill-region</a> <span class='i'>(start end)</span>
  <span class='i'>&quot;Kill the text between point and mark, like `kill-region&#39;.
If that text is unbalanced, signal an error instead.
With a prefix argument, skip the balance check.&quot;</span>
  (<a id='4610' tid='4609' class='u'>interactive</a> <a id='4612' tid='4611' class='u'>&quot;r&quot;</a>)
  <span class='i'>(if (and start end (not current-prefix-arg))
      (paredit-check-region-for-delete start end))</span>
  (<a id='4614' tid='4613' class='u'>setq</a> <a id='4616' tid='4615' class='u'>this-command</a> <a id='4618' tid='4617' class='u'>&#39;</a><a id='4620' tid='4619' class='u'>kill-region</a>)
  <span class='i'>(kill-region start end)</span>)

<span class='i'>(defun paredit-check-region-for-delete (start end)
  &quot;Signal an error deleting text between START and END is unsafe.&quot;
  (save-excursion
    (goto-char start)
    (let* ((start-state (paredit-current-parse-state))
           (end-state (parse-partial-sexp start end nil nil start-state)))
      (paredit-check-region-for-delete:depth start start-state end end-state)
      (paredit-check-region-for-delete:string start start-state end end-state)
      (paredit-check-region-for-delete:comment start start-state end end-state)
      (paredit-check-region-for-delete:char-quote start start-state
                                                  end end-state))))</span>

<span class='i'>(defun paredit-check-region-for-delete:depth (start start-state end end-state)
  (let ((start-depth (nth 0 start-state))
        (end-depth (nth 0 end-state)))
    (if (not (= start-depth end-depth))
        (error &quot;Mismatched parenthesis depth: %S at start, %S at end.&quot;
               start-depth
               end-depth))))</span>

<span class='i'>(defun paredit-check-region-for-delete:string (start start-state end end-state)
  (let ((start-string-p (nth 3 start-state))
        (end-string-p (nth 3 end-state)))
    (if (not (eq start-string-p end-string-p))
        (error &quot;Mismatched string state: start %sin string, end %sin string.&quot;
               (if start-string-p &quot;&quot; &quot;not &quot;)
               (if end-string-p &quot;&quot; &quot;not &quot;)))))</span>

<span class='i'>(defun paredit-check-region-for-delete:comment
    (start start-state end end-state)
  (let ((start-comment-state (nth 4 start-state))
        (end-comment-state (nth 4 end-state)))
    (if (not (or (eq start-comment-state end-comment-state)
                 ;; If we are moving text into or out of a line
                 ;; comment, make sure that the text is balanced.  (The
                 ;; comment state may be a number, not t or nil at all,
                 ;; for nestable comments, which are not handled by
                 ;; this heuristic (or any of paredit, really).)
                 (and (or (and (eq start-comment-state nil)
                               (eq end-comment-state t))
                          (and (eq start-comment-state t)
                               (eq end-comment-state nil)))
                      (save-excursion
                        (goto-char end)
                        (paredit-region-ok-p (point) (point-at-eol))))))
        (error &quot;Mismatched comment state: %s&quot;
               (cond ((and (integerp start-comment-state)
                           (integerp end-comment-state))
                      (format &quot;depth %S at start, depth %S at end.&quot;
                              start-comment-state
                              end-comment-state))
                     ((integerp start-comment-state)
                      &quot;start in nested comment, end otherwise.&quot;)
                     ((integerp end-comment-state)
                      &quot;end in nested comment, start otherwise.&quot;)
                     (start-comment-state
                      &quot;start in comment, end not in comment.&quot;)
                     (end-comment-state
                      &quot;end in comment, start not in comment.&quot;)
                     (t
                      (format &quot;start %S, end %S.&quot;
                              start-comment-state
                              end-comment-state)))))))</span>

<span class='i'>(defun paredit-check-region-for-delete:char-quote
    (start start-state end end-state)
  (let ((start-char-quote (nth 5 start-state))
        (end-char-quote (nth 5 end-state)))
    (if (not (eq start-char-quote end-char-quote))
        (let ((phrase &quot;character quotation&quot;))
          (error &quot;Mismatched %s: start %sin %s, end %sin %s.&quot;
                 phrase
                 (if start-char-quote &quot;&quot; &quot;not &quot;)
                 phrase
                 (if end-char-quote &quot;&quot; &quot;not &quot;)
                 phrase)))))</span>

<span class='i'>;;;; Point Motion
</span>
(<a id='7372' tid='7371' class='u'>eval-and-compile</a>
  (<a id='7410' tid='7409' class='u'>defmacro</a> <a id='7412' tid='7411' class='u'>defun-saving-mark</a> (<a id='7414' tid='7413' class='u'>name</a> <a id='7416' tid='7415' class='u'>bvl</a> <a id='7418' tid='7417' class='u'>doc</a> <a id='7420' tid='7419' class='u'>&rest</a> <a id='7422' tid='7421' class='u'>body</a>)
    <a id='7424' tid='7423' class='u'>`</a>(<a id='7374' tid='7373' class='u'>defun</a> <a id='7376' tid='7375' class='u'>,</a><a id='7378' tid='7377' class='u'>name</a> <a id='7380' tid='7379' class='u'>,</a><a id='7382' tid='7381' class='u'>bvl</a>
       <a id='7384' tid='7383' class='u'>,</a><a id='7386' tid='7385' class='u'>doc</a>
       <a id='7388' tid='7387' class='u'>,</a>(<a id='7390' tid='7389' class='u'>xcond</a> ((<a id='7392' tid='7391' class='u'>paredit-xemacs-p</a>)
                <a id='7394' tid='7393' class='u'>&#39;</a>(<a id='7396' tid='7395' class='u'>interactive</a> <a id='7398' tid='7397' class='u'>&quot;_&quot;</a>))
               ((<a id='7400' tid='7399' class='u'>paredit-gnu-emacs-p</a>)
                <a id='7402' tid='7401' class='u'>&#39;</a>(<a id='7404' tid='7403' class='u'>interactive</a>)))
       <a id='7406' tid='7405' class='u'>,</a><a id='7408' tid='7407' class='u'>@body</a>)))

(<a id='7426' tid='7425' class='u'>defun-saving-mark</a> <a id='7428' tid='7427' class='u'>paredit-forward</a> ()
  <a id='7430' tid='7429' class='u'>&quot;Move forward an S-expression, or up an S-expression forward.
If there are no more S-expressions in this one before the closing
  delimiter, move past that closing delimiter; otherwise, move forward
  past the S-expression following the point.&quot;</a>
  (<a id='7432' tid='7431' class='u'>paredit-handle-sexp-errors</a>
      (<a id='7434' tid='7433' class='u'>forward-sexp</a>)
    <span class='i'>;; Use `up-list&#39; if outside a string in case there is whitespace
</span>    <span class='i'>;; between the point and the end of the list.
</span>    (<a id='7436' tid='7435' class='u'>if</a> (<a id='7438' tid='7437' class='u'>paredit-in-string-p</a>) (<a id='7440' tid='7439' class='u'>forward-char</a>) (<a id='7442' tid='7441' class='u'>up-list</a>))))

(<a id='7444' tid='7443' class='u'>defun-saving-mark</a> <a id='7446' tid='7445' class='u'>paredit-backward</a> ()
  <a id='7448' tid='7447' class='u'>&quot;Move backward an S-expression, or up an S-expression backward.
If there are no more S-expressions in this one before the opening
  delimiter, move past that opening delimiter backward; otherwise, move
  move backward past the S-expression preceding the point.&quot;</a>
  (<a id='7450' tid='7449' class='u'>paredit-handle-sexp-errors</a>
      (<a id='7452' tid='7451' class='u'>backward-sexp</a>)
    <span class='i'>;; Use `backward-up-list&#39; if outside a string in case there is
</span>    <span class='i'>;; whitespace between the point and the beginning of the list.
</span>    (<a id='7454' tid='7453' class='u'>if</a> (<a id='7456' tid='7455' class='u'>paredit-in-string-p</a>) (<a id='7458' tid='7457' class='u'>backward-char</a>) (<a id='7460' tid='7459' class='u'>backward-up-list</a>))))

<a id='7462' tid='7461' class='u'>;;; Why is this not in lisp.el?
</a>
(<a id='1742' tid='1741' class='u'>defun</a> <a id='1744' tid='1743' class='u'>backward-down-list</a> (<a id='1746' tid='1745' class='u'>&optional</a> <a id='1748' tid='1747' class='u'>arg</a>)
  <a id='1750' tid='1749' class='u'>&quot;Move backward and descend into one level of parentheses.
With ARG, do this that many times.
A negative argument means move forward but still descend a level.&quot;</a>
  (<a id='1752' tid='1751' class='u'>interactive</a> <a id='1754' tid='1753' class='u'>&quot;p&quot;</a>)
  (<a id='1756' tid='1755' class='u'>down-list</a> (<a id='1758' tid='1757' class='u'>-</a> (<a id='1760' tid='1759' class='u'>or</a> <a id='1762' tid='1761' class='u'>arg</a> <a id='1764' tid='1763' class='u'>1</a>))))

<span class='i'>;;;; Window Positioning
</span>
<span class='i'>(defalias &#39;paredit-recentre-on-sexp &#39;paredit-recenter-on-sexp)</span>

<span class='i'>(defun paredit-recenter-on-sexp (&optional n)
  &quot;Recenter the screen on the S-expression following the point.
With a prefix argument N, encompass all N S-expressions forward.&quot;
  (interactive &quot;P&quot;)
  (let* ((p (point))
         (end-point (progn (forward-sexp n) (point)))
         (start-point (progn (goto-char end-point) (backward-sexp n) (point))))
    ;; Point is at beginning of first S-expression.
    (let ((p-visible nil) (start-visible nil))
      (save-excursion
        (forward-line (/ (count-lines start-point end-point) 2))
        (recenter)
        (setq p-visible (pos-visible-in-window-p p))
        (setq start-visible (pos-visible-in-window-p start-point)))
      (cond ((not start-visible)
             ;; Implies (not p-visible).  Put the start at the top of
             ;; the screen.
             (recenter 0))
            (p-visible
             ;; Go back to p if we can.
             (goto-char p))))))</span>

<span class='i'>(defun paredit-recenter-on-defun ()
  &quot;Recenter the screen on the definition at point.&quot;
  (interactive)
  (save-excursion
    (beginning-of-defun)
    (paredit-recenter-on-sexp)))</span>

(<a id='3198' tid='3197' class='u'>defun</a> <a id='3200' tid='3199' class='u'>paredit-focus-on-defun</a> ()
  <a id='3202' tid='3201' class='u'>&quot;Moves display to the top of the definition at point.&quot;</a>
  (<a id='3204' tid='3203' class='u'>interactive</a>)
  (<a id='3206' tid='3205' class='u'>beginning-of-defun</a>)
  (<a id='3208' tid='3207' class='u'>recenter</a> <a id='3210' tid='3209' class='u'>0</a>))

<span class='i'>;;;; Generalized Upward/Downward Motion
</span>
(<a id='6488' tid='6487' class='u'>defun</a> <a id='6490' tid='6489' class='u'>paredit-up/down</a> (<a id='6492' tid='6491' class='u'>n</a> <a id='6494' tid='6493' class='u'>vertical-direction</a>)
  (<a id='6496' tid='6495' class='u'>let</a> ((<a id='6498' tid='6497' class='u'>horizontal-direction</a> (<a id='6500' tid='6499' class='u'>if</a> (<a id='6502' tid='6501' class='u'>&lt;</a> <a id='6504' tid='6503' class='u'>0</a> <a id='6506' tid='6505' class='u'>n</a>) <a id='6508' tid='6507' class='u'>+1</a> <a id='6510' tid='6509' class='u'>-1</a>)))
    (<a id='6512' tid='6511' class='u'>while</a> (<a id='6514' tid='6513' class='u'>/=</a> <a id='6516' tid='6515' class='u'>n</a> <a id='6518' tid='6517' class='u'>0</a>)
      (<a id='6520' tid='6519' class='u'>goto-char</a>
       (<a id='6522' tid='6521' class='u'>paredit-next-up/down-point</a> <a id='6524' tid='6523' class='u'>horizontal-direction</a> <a id='6526' tid='6525' class='u'>vertical-direction</a>))
      (<a id='6528' tid='6527' class='u'>setq</a> <a id='6530' tid='6529' class='u'>n</a> (<a id='6532' tid='6531' class='u'>-</a> <a id='6534' tid='6533' class='u'>n</a> <a id='6536' tid='6535' class='u'>horizontal-direction</a>)))))

(<a id='5468' tid='5467' class='u'>defun</a> <a id='5470' tid='5469' class='u'>paredit-next-up/down-point</a> (<a id='5472' tid='5471' class='u'>horizontal-direction</a> <a id='5474' tid='5473' class='u'>vertical-direction</a>)
  (<a id='5476' tid='5475' class='u'>let</a> ((<a id='5478' tid='5477' class='u'>state</a> (<a id='5480' tid='5479' class='u'>paredit-current-parse-state</a>))
        (<a id='5482' tid='5481' class='u'>scan-lists</a>
         (<a id='5484' tid='5483' class='u'>lambda</a> ()
           (<a id='5486' tid='5485' class='u'>scan-lists</a> (<a id='5488' tid='5487' class='u'>point</a>) <a id='5490' tid='5489' class='u'>horizontal-direction</a> <a id='5492' tid='5491' class='u'>vertical-direction</a>))))
    (<a id='5494' tid='5493' class='u'>cond</a> ((<a id='5496' tid='5495' class='u'>paredit-in-string-p</a> <a id='5498' tid='5497' class='u'>state</a>)
           (<a id='5500' tid='5499' class='u'>let</a> ((<a id='5502' tid='5501' class='u'>start+end</a> (<a id='5504' tid='5503' class='u'>paredit-string-start+end-points</a> <a id='5506' tid='5505' class='u'>state</a>)))
             (<a id='5508' tid='5507' class='u'>if</a> (<a id='5510' tid='5509' class='u'>&lt;</a> <a id='5512' tid='5511' class='u'>0</a> <a id='5514' tid='5513' class='u'>vertical-direction</a>)
                 (<a id='5516' tid='5515' class='u'>if</a> (<a id='5518' tid='5517' class='u'>&lt;</a> <a id='5520' tid='5519' class='u'>0</a> <a id='5522' tid='5521' class='u'>horizontal-direction</a>)
                     (<a id='5524' tid='5523' class='u'>+</a> <a id='5526' tid='5525' class='u'>1</a> (<a id='5528' tid='5527' class='u'>cdr</a> <a id='5530' tid='5529' class='u'>start+end</a>))
                     (<a id='5532' tid='5531' class='u'>car</a> <a id='5534' tid='5533' class='u'>start+end</a>))
                 <a id='5536' tid='5535' class='u'>;; We could let the user try to descend into lists
</a>                 <a id='5538' tid='5537' class='u'>;; within the string, but that would be asymmetric
</a>                 <a id='5540' tid='5539' class='u'>;; with the up case, which rises out of the whole
</a>                 <a id='5542' tid='5541' class='u'>;; string and not just out of a list within the
</a>                 <a id='5544' tid='5543' class='u'>;; string, so this case will just be an error.
</a>                 (<a id='5546' tid='5545' class='u'>error</a> <a id='5548' tid='5547' class='u'>&quot;Can&#39;t descend further into string.&quot;</a>))))
          ((<a id='5550' tid='5549' class='u'>&lt;</a> <a id='5552' tid='5551' class='u'>0</a> <a id='5554' tid='5553' class='u'>vertical-direction</a>)
           <a id='5556' tid='5555' class='u'>;; When moving up, just try to rise up out of the list.
</a>           (<a id='5558' tid='5557' class='u'>or</a> (<a id='5560' tid='5559' class='u'>funcall</a> <a id='5562' tid='5561' class='u'>scan-lists</a>)
               (<a id='5564' tid='5563' class='u'>buffer-end</a> <a id='5566' tid='5565' class='u'>horizontal-direction</a>)))
          ((<a id='5568' tid='5567' class='u'>&lt;</a> <a id='5570' tid='5569' class='u'>vertical-direction</a> <a id='5572' tid='5571' class='u'>0</a>)
           <a id='5574' tid='5573' class='u'>;; When moving down, look for a string closer than a list,
</a>           <a id='5576' tid='5575' class='u'>;; and use that if we find it.
</a>           (<a id='5578' tid='5577' class='u'>let*</a> ((<a id='5580' tid='5579' class='u'>list-start</a>
                   (<a id='5582' tid='5581' class='u'>paredit-handle-sexp-errors</a> (<a id='5584' tid='5583' class='u'>funcall</a> <a id='5586' tid='5585' class='u'>scan-lists</a>) <a id='5588' tid='5587' class='u'>nil</a>))
                  (<a id='5590' tid='5589' class='u'>string-start</a>
                   (<a id='5592' tid='5591' class='u'>paredit-find-next-string-start</a> <a id='5594' tid='5593' class='u'>horizontal-direction</a>
                                                   <a id='5596' tid='5595' class='u'>list-start</a>)))
             (<a id='5598' tid='5597' class='u'>if</a> (<a id='5600' tid='5599' class='u'>and</a> <a id='5602' tid='5601' class='u'>string-start</a> <a id='5604' tid='5603' class='u'>list-start</a>)
                 (<a id='5606' tid='5605' class='u'>if</a> (<a id='5608' tid='5607' class='u'>&lt;</a> <a id='5610' tid='5609' class='u'>0</a> <a id='5612' tid='5611' class='u'>horizontal-direction</a>)
                     (<a id='5614' tid='5613' class='u'>min</a> <a id='5616' tid='5615' class='u'>string-start</a> <a id='5618' tid='5617' class='u'>list-start</a>)
                     (<a id='5620' tid='5619' class='u'>max</a> <a id='5622' tid='5621' class='u'>string-start</a> <a id='5624' tid='5623' class='u'>list-start</a>))
                 (<a id='5626' tid='5625' class='u'>or</a> <a id='5628' tid='5627' class='u'>string-start</a>
                     <a id='5630' tid='5629' class='u'>;; Scan again: this is a kludgey way to report the
</a>                     <a id='5632' tid='5631' class='u'>;; error if there really was one.
</a>                     (<a id='5634' tid='5633' class='u'>funcall</a> <a id='5636' tid='5635' class='u'>scan-lists</a>)
                     (<a id='5638' tid='5637' class='u'>buffer-end</a> <a id='5640' tid='5639' class='u'>horizontal-direction</a>)))))
          (<a id='5642' tid='5641' class='u'>t</a>
           (<a id='5644' tid='5643' class='u'>error</a> <a id='5646' tid='5645' class='u'>&quot;Vertical direction must be nonzero in `%s&#39;.&quot;</a>
                  <a id='5648' tid='5647' class='u'>&#39;</a><a id='5650' tid='5649' class='u'>paredit-up/down</a>)))))

(<a id='3190' tid='3189' class='u'>defun</a> <a id='3192' tid='3191' class='u'>paredit-find-next-string-start</a> (<a id='3194' tid='3193' class='u'>horizontal-direction</a> <a id='3196' tid='3195' class='u'>limit</a>)
  (<a id='1278' tid='1277' class='m'>let</a> (<span class='i'>(buffer-limit-p (if (&lt; 0 horizontal-direction) &#39;eobp &#39;bobp))</span>
        (<a id='1280' tid='1279' class='m'>next-char</a> (<a id='1282' tid='1281' class='m'>if</a> (<a id='1284' tid='1283' class='m'>&lt;</a> <a id='1286' tid='1285' class='m'>0</a> <a id='1288' tid='1287' class='m'>horizontal-direction</a>) <a id='1290' tid='1289' class='m'>&#39;</a><a id='1292' tid='1291' class='m'>char-after</a> <a id='1294' tid='1293' class='m'>&#39;</a><a id='1296' tid='1295' class='m'>char-before</a>))
        <span class='i'>(pastp (if (&lt; 0 horizontal-direction) &#39;&gt; &#39;&lt;))</span>)
    (<a id='1298' tid='1297' class='m'>paredit-handle-sexp-errors</a>
        (<a id='1300' tid='1299' class='m'>save-excursion</a>
          (<a id='1302' tid='1301' class='m'>catch</a> <a id='1304' tid='1303' class='m'>&#39;</a><a id='1306' tid='1305' class='m'>exit</a>
            (<a id='1308' tid='1307' class='m'>while</a> <a id='1310' tid='1309' class='m'>t</a>
              (<a id='1312' tid='1311' class='m'>if</a> (<span class='i'>or</span> <span class='i'>(funcall buffer-limit-p)</span>
                      (<a id='1314' tid='1313' class='m'>and</a> <a id='1316' tid='1315' class='m'>limit</a> (<a id='1318' tid='1317' class='m'>funcall</a> <a id='1320' tid='1319' class='m'>pastp</a> (<a id='1322' tid='1321' class='m'>point</a>) <a id='1324' tid='1323' class='m'>limit</a>)))
                  (<a id='1326' tid='1325' class='m'>throw</a> <a id='1328' tid='1327' class='m'>&#39;</a><a id='1330' tid='1329' class='m'>exit</a> <a id='1332' tid='1331' class='m'>nil</a>))
              (<a id='1334' tid='1333' class='m'>forward-sexp</a> <a id='1336' tid='1335' class='m'>horizontal-direction</a>)
              (<a id='1338' tid='1337' class='m'>save-excursion</a>
                (<a id='1340' tid='1339' class='m'>backward-sexp</a> <a id='1342' tid='1341' class='m'>horizontal-direction</a>)
                (<a id='1344' tid='1343' class='m'>if</a> (<a id='1346' tid='1345' class='m'>eq</a> <a id='1348' tid='1347' class='m'>?\&quot;</a> (<a id='1350' tid='1349' class='m'>char-syntax</a> (<a id='1352' tid='1351' class='m'>funcall</a> <a id='1354' tid='1353' class='m'>next-char</a>)))
                    (<a id='1356' tid='1355' class='m'>throw</a> <a id='1358' tid='1357' class='m'>&#39;</a><a id='1360' tid='1359' class='m'>exit</a> (<a id='1362' tid='1361' class='m'>+</a> (<a id='1364' tid='1363' class='m'>point</a>) <a id='1366' tid='1365' class='m'>horizontal-direction</a>)))))))
      <a id='1368' tid='1367' class='m'>nil</a>)))

(<a id='3350' tid='3349' class='u'>defun</a> <a id='3352' tid='3351' class='u'>paredit-forward-down</a> (<a id='3354' tid='3353' class='u'>&optional</a> <a id='3356' tid='3355' class='u'>argument</a>)
  <a id='3358' tid='3357' class='u'>&quot;Move forward down into a list.
With a positive argument, move forward down that many levels.
With a negative argument, move backward down that many levels.&quot;</a>
  (<a id='3360' tid='3359' class='u'>interactive</a> <a id='3362' tid='3361' class='u'>&quot;p&quot;</a>)
  (<a id='3364' tid='3363' class='u'>paredit-up/down</a> (<a id='3366' tid='3365' class='u'>or</a> <a id='3368' tid='3367' class='u'>argument</a> <a id='3370' tid='3369' class='u'>+1</a>) <a id='3372' tid='3371' class='u'>-1</a>))

(<a id='2542' tid='2541' class='u'>defun</a> <a id='2544' tid='2543' class='u'>paredit-backward-up</a> (<a id='2546' tid='2545' class='u'>&optional</a> <a id='2548' tid='2547' class='u'>argument</a>)
  <a id='2550' tid='2549' class='u'>&quot;Move backward up out of the enclosing list.
With a positive argument, move backward up that many levels.
With a negative argument, move forward up that many levels.
If in a string initially, that counts as one level.&quot;</a>
  (<a id='2552' tid='2551' class='u'>interactive</a> <a id='2554' tid='2553' class='u'>&quot;p&quot;</a>)
  (<a id='2556' tid='2555' class='u'>paredit-up/down</a> (<a id='2558' tid='2557' class='u'>-</a> <a id='2560' tid='2559' class='u'>0</a> (<a id='2562' tid='2561' class='u'>or</a> <a id='2564' tid='2563' class='u'>argument</a> <a id='2566' tid='2565' class='u'>+1</a>)) <a id='2568' tid='2567' class='u'>+1</a>))

(<a id='3886' tid='3885' class='u'>defun</a> <a id='3888' tid='3887' class='u'>paredit-forward-up</a> (<a id='3890' tid='3889' class='u'>&optional</a> <a id='3892' tid='3891' class='u'>argument</a>)
  <a id='3894' tid='3893' class='u'>&quot;Move forward up out of the enclosing list.
With a positive argument, move forward up that many levels.
With a negative argument, move backward up that many levels.
If in a string initially, that counts as one level.&quot;</a>
  (<a id='3896' tid='3895' class='u'>interactive</a> <a id='3898' tid='3897' class='u'>&quot;p&quot;</a>)
  (<a id='3900' tid='3899' class='u'>paredit-up/down</a> (<a id='3902' tid='3901' class='u'>or</a> <a id='3904' tid='3903' class='u'>argument</a> <a id='3906' tid='3905' class='u'>+1</a>) <a id='3908' tid='3907' class='u'>+1</a>))

(<a id='2218' tid='2217' class='u'>defun</a> <a id='2220' tid='2219' class='u'>paredit-backward-down</a> (<a id='2222' tid='2221' class='u'>&optional</a> <a id='2224' tid='2223' class='u'>argument</a>)
  <a id='2226' tid='2225' class='u'>&quot;Move backward down into a list.
With a positive argument, move backward down that many levels.
With a negative argument, move forward down that many levels.&quot;</a>
  (<a id='2228' tid='2227' class='u'>interactive</a> <a id='2230' tid='2229' class='u'>&quot;p&quot;</a>)
  (<a id='2232' tid='2231' class='u'>paredit-up/down</a> (<a id='2234' tid='2233' class='u'>-</a> <a id='2236' tid='2235' class='u'>0</a> (<a id='2238' tid='2237' class='u'>or</a> <a id='2240' tid='2239' class='u'>argument</a> <a id='2242' tid='2241' class='u'>+1</a>)) <a id='2244' tid='2243' class='u'>-1</a>))

<span class='i'>;;;; Depth-Changing Commands:  Wrapping, Splicing, & Raising
</span>
(<a id='6548' tid='6547' class='u'>defun</a> <a id='6550' tid='6549' class='u'>paredit-wrap-sexp</a> (<a id='6552' tid='6551' class='u'>&optional</a> <a id='6554' tid='6553' class='u'>argument</a> <a id='6556' tid='6555' class='u'>open</a> <a id='6558' tid='6557' class='u'>close</a>)
  <a id='6560' tid='6559' class='u'>&quot;Wrap the following S-expression.
If a `C-u&#39; prefix argument is given, wrap all S-expressions following
  the point until the end of the buffer or of the enclosing list.
If a numeric prefix argument N is given, wrap N S-expressions.
Automatically indent the newly wrapped S-expression.
As a special case, if the point is at the end of a list, simply insert
  a parenthesis pair, rather than inserting a lone opening delimiter
  and then signalling an error, in the interest of preserving
  structure.
By default OPEN and CLOSE are round delimiters.&quot;</a>
  (<a id='6562' tid='6561' class='u'>interactive</a> <a id='6564' tid='6563' class='u'>&quot;P&quot;</a>)
  (<a id='6566' tid='6565' class='u'>paredit-lose-if-not-in-sexp</a> <a id='6568' tid='6567' class='u'>&#39;</a><a id='6570' tid='6569' class='u'>paredit-wrap-sexp</a>)
  (<a id='6572' tid='6571' class='u'>let</a> ((<a id='6574' tid='6573' class='u'>open</a> (<a id='6576' tid='6575' class='u'>or</a> <a id='6578' tid='6577' class='u'>open</a> <a id='6580' tid='6579' class='u'>?\(</a> ))
        (<a id='6582' tid='6581' class='u'>close</a> (<a id='6584' tid='6583' class='u'>or</a> <a id='6586' tid='6585' class='u'>close</a> <a id='6588' tid='6587' class='u'>?\)</a> )))
    (<a id='6590' tid='6589' class='u'>paredit-handle-sexp-errors</a>
        ((<a id='6592' tid='6591' class='u'>lambda</a> (<a id='6594' tid='6593' class='u'>n</a>) (<a id='6596' tid='6595' class='u'>paredit-insert-pair</a> <a id='6598' tid='6597' class='u'>n</a> <a id='6600' tid='6599' class='u'>open</a> <a id='6602' tid='6601' class='u'>close</a> <a id='6604' tid='6603' class='u'>&#39;</a><a id='6606' tid='6605' class='u'>goto-char</a>))
         (<a id='6608' tid='6607' class='u'>cond</a> ((<a id='6610' tid='6609' class='u'>integerp</a> <a id='6612' tid='6611' class='u'>argument</a>) <a id='6614' tid='6613' class='u'>argument</a>)
               ((<a id='6616' tid='6615' class='u'>consp</a> <a id='6618' tid='6617' class='u'>argument</a>) (<a id='6620' tid='6619' class='u'>paredit-count-sexps-forward</a>))
               ((<a id='6622' tid='6621' class='u'>paredit-region-active-p</a>) <a id='6624' tid='6623' class='u'>nil</a>)
               (<a id='6626' tid='6625' class='u'>t</a> <a id='6628' tid='6627' class='u'>1</a>)))
      (<a id='6630' tid='6629' class='u'>insert</a> <a id='6632' tid='6631' class='u'>close</a>)
      (<a id='6634' tid='6633' class='u'>backward-char</a>)))
  (<a id='6636' tid='6635' class='u'>save-excursion</a> (<a id='6638' tid='6637' class='u'>backward-up-list</a>) (<a id='6640' tid='6639' class='u'>indent-sexp</a>)))

(<a id='2928' tid='2927' class='u'>defun</a> <a id='2930' tid='2929' class='u'>paredit-count-sexps-forward</a> ()
  (<a id='1370' tid='1369' class='m'>save-excursion</a>
    (<span class='i'>let</span> <span class='i'>((n 0) (p nil))</span>                <span class='i'>;hurk
</span>      (<span class='i'>paredit-ignore-sexp-errors</span>
        (<span class='i'>while</span> <span class='i'>(setq p (scan-sexps (point) +1))</span>
          <span class='i'>(goto-char p)</span>
          (<a id='1372' tid='1371' class='m'>setq</a> <a id='1374' tid='1373' class='m'>n</a> (<a id='1376' tid='1375' class='m'>+</a> <a id='1378' tid='1377' class='m'>n</a> <a id='1380' tid='1379' class='m'>1</a>))))
      <span class='i'>n</span>)))

(<a id='6642' tid='6641' class='u'>defun</a> <a id='6644' tid='6643' class='u'>paredit-yank-pop</a> (<a id='6646' tid='6645' class='u'>&optional</a> <a id='6648' tid='6647' class='u'>argument</a>)
  <a id='6650' tid='6649' class='u'>&quot;Replace just-yanked text with the next item in the kill ring.
If this command follows a `yank&#39;, just run `yank-pop&#39;.
If this command follows a `paredit-wrap-sexp&#39;, or any other paredit
  wrapping command (see `paredit-wrap-commands&#39;), run `yank&#39; and
  reindent the enclosing S-expression.
If this command is repeated, run `yank-pop&#39; and reindent the enclosing
  S-expression.

The argument is passed on to `yank&#39; or `yank-pop&#39;; see their
  documentation for details.&quot;</a>
  (<a id='6652' tid='6651' class='u'>interactive</a> <a id='6654' tid='6653' class='u'>&quot;*p&quot;</a>)
  (<a id='6656' tid='6655' class='u'>cond</a> ((<a id='6658' tid='6657' class='u'>eq</a> <a id='6660' tid='6659' class='u'>last-command</a> <a id='6662' tid='6661' class='u'>&#39;</a><a id='6664' tid='6663' class='u'>yank</a>)
         (<a id='6666' tid='6665' class='u'>yank-pop</a> <a id='6668' tid='6667' class='u'>argument</a>))
        ((<a id='6670' tid='6669' class='u'>memq</a> <a id='6672' tid='6671' class='u'>last-command</a> <a id='6674' tid='6673' class='u'>paredit-wrap-commands</a>)
         (<a id='6676' tid='6675' class='u'>yank</a> <a id='6678' tid='6677' class='u'>argument</a>)
         <a id='6680' tid='6679' class='u'>;; `yank&#39; futzes with `this-command&#39;.
</a>         (<a id='6682' tid='6681' class='u'>setq</a> <a id='6684' tid='6683' class='u'>this-command</a> <a id='6686' tid='6685' class='u'>&#39;</a><a id='6688' tid='6687' class='u'>paredit-yank-pop</a>)
         (<a id='6690' tid='6689' class='u'>save-excursion</a> (<a id='6692' tid='6691' class='u'>backward-up-list</a>) (<a id='6694' tid='6693' class='u'>indent-sexp</a>)))
        ((<a id='6696' tid='6695' class='u'>eq</a> <a id='6698' tid='6697' class='u'>last-command</a> <a id='6700' tid='6699' class='u'>&#39;</a><a id='6702' tid='6701' class='u'>paredit-yank-pop</a>)
         <a id='6704' tid='6703' class='u'>;; Pretend we just did a `yank&#39;, so that we can use
</a>         <a id='6706' tid='6705' class='u'>;; `yank-pop&#39; without duplicating its definition.
</a>         (<a id='6708' tid='6707' class='u'>setq</a> <a id='6710' tid='6709' class='u'>last-command</a> <a id='6712' tid='6711' class='u'>&#39;</a><a id='6714' tid='6713' class='u'>yank</a>)
         (<a id='6716' tid='6715' class='u'>yank-pop</a> <a id='6718' tid='6717' class='u'>argument</a>)
         <a id='6720' tid='6719' class='u'>;; Return to our original state.
</a>         (<a id='6722' tid='6721' class='u'>setq</a> <a id='6724' tid='6723' class='u'>last-command</a> <a id='6726' tid='6725' class='u'>&#39;</a><a id='6728' tid='6727' class='u'>paredit-yank-pop</a>)
         (<a id='6730' tid='6729' class='u'>setq</a> <a id='6732' tid='6731' class='u'>this-command</a> <a id='6734' tid='6733' class='u'>&#39;</a><a id='6736' tid='6735' class='u'>paredit-yank-pop</a>)
         (<a id='6738' tid='6737' class='u'>save-excursion</a> (<a id='6740' tid='6739' class='u'>backward-up-list</a>) (<a id='6742' tid='6741' class='u'>indent-sexp</a>)))
        (<a id='6744' tid='6743' class='u'>t</a> (<a id='6746' tid='6745' class='u'>error</a> <a id='6748' tid='6747' class='u'>&quot;Last command was not a yank or a wrap: %s&quot;</a> <a id='6750' tid='6749' class='u'>last-command</a>))))

(<a id='6150' tid='6149' class='u'>defun</a> <a id='6152' tid='6151' class='u'>paredit-splice-sexp</a> (<a id='6154' tid='6153' class='u'>&optional</a> <a id='6156' tid='6155' class='u'>argument</a>)
  <a id='6158' tid='6157' class='u'>&quot;Splice the list that the point is on by removing its delimiters.
With a prefix argument as in `C-u&#39;, kill all S-expressions backward in
  the current list before splicing all S-expressions forward into the
  enclosing list.
With two prefix arguments as in `C-u C-u&#39;, kill all S-expressions
  forward in the current list before splicing all S-expressions
  backward into the enclosing list.
With a numerical prefix argument N, kill N S-expressions backward in
  the current list before splicing the remaining S-expressions into the
  enclosing list.  If N is negative, kill forward.
Inside a string, unescape all backslashes, or signal an error if doing
  so would invalidate the buffer&#39;s structure.&quot;</a>
  (<a id='6160' tid='6159' class='u'>interactive</a> <a id='6162' tid='6161' class='u'>&quot;P&quot;</a>)
  (<a id='1382' tid='1381' class='m'>if</a> (<a id='1384' tid='1383' class='m'>paredit-in-string-p</a>)
      (<a id='1386' tid='1385' class='m'>paredit-splice-string</a> <a id='1388' tid='1387' class='m'>argument</a>)
      (<a id='1390' tid='1389' class='m'>save-excursion</a>
        (<a id='1392' tid='1391' class='m'>paredit-kill-surrounding-sexps-for-splice</a> <a id='1394' tid='1393' class='m'>argument</a>)
        (<a id='1396' tid='1395' class='m'>let</a> ((<a id='1398' tid='1397' class='m'>end</a> (<a id='1400' tid='1399' class='m'>point</a>)))
          (<a id='1402' tid='1401' class='m'>backward-up-list</a>)            <a id='1404' tid='1403' class='m'>; Go up to the beginning...
</a>          (<a id='1406' tid='1405' class='m'>save-excursion</a>
            (<a id='1408' tid='1407' class='m'>forward-char</a> <a id='1410' tid='1409' class='m'>1</a>)            <a id='1412' tid='1411' class='m'>; (Skip over leading whitespace
</a>            (<a id='1414' tid='1413' class='m'>paredit-skip-whitespace</a> <a id='1416' tid='1415' class='m'>t</a> <a id='1418' tid='1417' class='m'>end</a>)
            (<a id='1420' tid='1419' class='m'>setq</a> <a id='1422' tid='1421' class='m'>end</a> (<a id='1424' tid='1423' class='m'>point</a>)))         <a id='1426' tid='1425' class='m'>;   for the `delete-region&#39;.)
</a>          (<span class='i'>let</span> <span class='i'>((indent-start nil) (indent-end nil))</span>
            (<a id='1428' tid='1427' class='m'>save-excursion</a>
              (<a id='1430' tid='1429' class='m'>setq</a> <a id='1432' tid='1431' class='m'>indent-start</a> (<a id='1434' tid='1433' class='m'>point</a>))
              (<a id='1436' tid='1435' class='m'>forward-sexp</a>)            <a id='1438' tid='1437' class='m'>; Go forward an expression, to
</a>              (<a id='1440' tid='1439' class='m'>backward-delete-char</a> <a id='1442' tid='1441' class='m'>1</a>)  <a id='1444' tid='1443' class='m'>;   delete the end delimiter.
</a>              (<a id='1446' tid='1445' class='m'>setq</a> <a id='1448' tid='1447' class='m'>indent-end</a> (<a id='1450' tid='1449' class='m'>point</a>)))
            <span class='i'>(delete-region (point) end)</span> <span class='i'>; ...to delete the open char.
</span>            <span class='i'>;; Reindent only the region we preserved.
</span>            <span class='i'>(indent-region indent-start indent-end nil)</span>)))))

(<a id='4860' tid='4859' class='u'>defun</a> <a id='4862' tid='4861' class='u'>paredit-kill-surrounding-sexps-for-splice</a> (<a id='4864' tid='4863' class='u'>argument</a>)
  (<a id='4866' tid='4865' class='u'>cond</a> ((<a id='4868' tid='4867' class='u'>or</a> (<a id='4870' tid='4869' class='u'>paredit-in-string-p</a>)
             (<a id='4872' tid='4871' class='u'>paredit-in-comment-p</a>))
         (<a id='4874' tid='4873' class='u'>error</a> <a id='4876' tid='4875' class='u'>&quot;Invalid context for splicing S-expressions.&quot;</a>))
        ((<a id='4878' tid='4877' class='u'>or</a> (<a id='4880' tid='4879' class='u'>not</a> <a id='4882' tid='4881' class='u'>argument</a>) (<a id='4884' tid='4883' class='u'>eq</a> <a id='4886' tid='4885' class='u'>argument</a> <a id='4888' tid='4887' class='u'>0</a>)) <a id='4890' tid='4889' class='u'>nil</a>)
        ((<a id='4892' tid='4891' class='u'>or</a> (<a id='4894' tid='4893' class='u'>numberp</a> <a id='4896' tid='4895' class='u'>argument</a>) (<a id='4898' tid='4897' class='u'>eq</a> <a id='4900' tid='4899' class='u'>argument</a> <a id='4902' tid='4901' class='u'>&#39;</a><a id='4904' tid='4903' class='u'>-</a>))
         <a id='4906' tid='4905' class='u'>;; Kill S-expressions before/after the point by saving the
</a>         <a id='4908' tid='4907' class='u'>;; point, moving across them, and killing the region.
</a>         (<a id='4910' tid='4909' class='u'>let*</a> ((<a id='4912' tid='4911' class='u'>argument</a> (<a id='4914' tid='4913' class='u'>if</a> (<a id='4916' tid='4915' class='u'>eq</a> <a id='4918' tid='4917' class='u'>argument</a> <a id='4920' tid='4919' class='u'>&#39;</a><a id='4922' tid='4921' class='u'>-</a>) <a id='4924' tid='4923' class='u'>-1</a> <a id='4926' tid='4925' class='u'>argument</a>))
                (<a id='4928' tid='4927' class='u'>saved</a> (<a id='4930' tid='4929' class='u'>paredit-point-at-sexp-boundary</a> (<a id='4932' tid='4931' class='u'>-</a> <a id='4934' tid='4933' class='u'>argument</a>))))
           (<a id='4936' tid='4935' class='u'>goto-char</a> <a id='4938' tid='4937' class='u'>saved</a>)
           (<a id='4940' tid='4939' class='u'>paredit-ignore-sexp-errors</a> (<a id='4942' tid='4941' class='u'>backward-sexp</a> <a id='4944' tid='4943' class='u'>argument</a>))
           (<a id='4946' tid='4945' class='u'>paredit-hack-kill-region</a> <a id='4948' tid='4947' class='u'>saved</a> (<a id='4950' tid='4949' class='u'>point</a>))))
        ((<a id='4952' tid='4951' class='u'>consp</a> <a id='4954' tid='4953' class='u'>argument</a>)
         (<a id='4956' tid='4955' class='u'>let</a> ((<a id='4958' tid='4957' class='u'>v</a> (<a id='4960' tid='4959' class='u'>car</a> <a id='4962' tid='4961' class='u'>argument</a>)))
           (<a id='4964' tid='4963' class='u'>if</a> (<a id='4966' tid='4965' class='u'>=</a> <a id='4968' tid='4967' class='u'>v</a> <a id='4970' tid='4969' class='u'>4</a>)                  <a id='4972' tid='4971' class='u'>;One `C-u&#39;.
</a>               <a id='4974' tid='4973' class='u'>;; Move backward until we hit the open paren; then
</a>               <a id='4976' tid='4975' class='u'>;; kill that selected region.
</a>               (<a id='4978' tid='4977' class='u'>let</a> ((<a id='4980' tid='4979' class='u'>end</a> (<a id='4982' tid='4981' class='u'>point</a>)))
                 (<a id='4984' tid='4983' class='u'>paredit-ignore-sexp-errors</a>
                   (<a id='4986' tid='4985' class='u'>while</a> (<a id='4988' tid='4987' class='u'>not</a> (<a id='4990' tid='4989' class='u'>bobp</a>))
                     (<a id='4992' tid='4991' class='u'>backward-sexp</a>)))
                 (<a id='4994' tid='4993' class='u'>paredit-hack-kill-region</a> (<a id='4996' tid='4995' class='u'>point</a>) <a id='4998' tid='4997' class='u'>end</a>))
               <a id='5000' tid='4999' class='u'>;; Move forward until we hit the close paren; then
</a>               <a id='5002' tid='5001' class='u'>;; kill that selected region.
</a>               (<a id='5004' tid='5003' class='u'>let</a> ((<a id='5006' tid='5005' class='u'>beginning</a> (<a id='5008' tid='5007' class='u'>point</a>)))
                 (<a id='5010' tid='5009' class='u'>paredit-ignore-sexp-errors</a>
                   (<a id='5012' tid='5011' class='u'>while</a> (<a id='5014' tid='5013' class='u'>not</a> (<a id='5016' tid='5015' class='u'>eobp</a>))
                     (<a id='5018' tid='5017' class='u'>forward-sexp</a>)))
                 (<a id='5020' tid='5019' class='u'>paredit-hack-kill-region</a> <a id='5022' tid='5021' class='u'>beginning</a> (<a id='5024' tid='5023' class='u'>point</a>))))))
        (<a id='5026' tid='5025' class='u'>t</a> (<a id='5028' tid='5027' class='u'>error</a> <a id='5030' tid='5029' class='u'>&quot;Bizarre prefix argument `%s&#39;.&quot;</a> <a id='5032' tid='5031' class='u'>argument</a>))))

(<a id='6164' tid='6163' class='u'>defun</a> <a id='6166' tid='6165' class='u'>paredit-splice-sexp-killing-backward</a> (<a id='6168' tid='6167' class='u'>&optional</a> <a id='6170' tid='6169' class='u'>n</a>)
  <a id='6172' tid='6171' class='u'>&quot;Splice the list the point is on by removing its delimiters, and
  also kill all S-expressions before the point in the current list.
With a prefix argument N, kill only the preceding N S-expressions.&quot;</a>
  (<a id='6174' tid='6173' class='u'>interactive</a> <a id='6176' tid='6175' class='u'>&quot;P&quot;</a>)
  (<a id='6178' tid='6177' class='u'>paredit-splice-sexp</a> (<a id='6180' tid='6179' class='u'>if</a> <a id='6182' tid='6181' class='u'>n</a>
                           (<a id='6184' tid='6183' class='u'>prefix-numeric-value</a> <a id='6186' tid='6185' class='u'>n</a>)
                           <a id='6188' tid='6187' class='u'>&#39;</a>(<a id='6190' tid='6189' class='u'>4</a>))))

(<a id='6192' tid='6191' class='u'>defun</a> <a id='6194' tid='6193' class='u'>paredit-splice-sexp-killing-forward</a> (<a id='6196' tid='6195' class='u'>&optional</a> <a id='6198' tid='6197' class='u'>n</a>)
  <a id='6200' tid='6199' class='u'>&quot;Splice the list the point is on by removing its delimiters, and
  also kill all S-expressions after the point in the current list.
With a prefix argument N, kill only the following N S-expressions.&quot;</a>
  (<a id='6202' tid='6201' class='u'>interactive</a> <a id='6204' tid='6203' class='u'>&quot;P&quot;</a>)
  (<a id='6206' tid='6205' class='u'>paredit-splice-sexp</a> (<a id='6208' tid='6207' class='u'>if</a> <a id='6210' tid='6209' class='u'>n</a>
                           (<a id='6212' tid='6211' class='u'>-</a> (<a id='6214' tid='6213' class='u'>prefix-numeric-value</a> <a id='6216' tid='6215' class='u'>n</a>))
                           <a id='6218' tid='6217' class='u'>&#39;</a>(<a id='6220' tid='6219' class='u'>16</a>))))

(<a id='5708' tid='5707' class='u'>defun</a> <a id='5710' tid='5709' class='u'>paredit-raise-sexp</a> (<a id='5712' tid='5711' class='u'>&optional</a> <a id='5714' tid='5713' class='u'>argument</a>)
  <a id='5716' tid='5715' class='u'>&quot;Raise the following S-expression in a tree, deleting its siblings.
With a prefix argument N, raise the following N S-expressions.  If N
  is negative, raise the preceding N S-expressions.
If the point is on an S-expression, such as a string or a symbol, not
  between them, that S-expression is considered to follow the point.&quot;</a>
  (<a id='5718' tid='5717' class='u'>interactive</a> <a id='5720' tid='5719' class='u'>&quot;P&quot;</a>)
  (<a id='1452' tid='1451' class='m'>save-excursion</a>
    (<a id='1454' tid='1453' class='m'>cond</a> ((<a id='1456' tid='1455' class='m'>paredit-in-string-p</a>)
           (<a id='1458' tid='1457' class='m'>goto-char</a> (<a id='1460' tid='1459' class='m'>car</a> (<a id='1462' tid='1461' class='m'>paredit-string-start+end-points</a>))))
          ((<a id='1464' tid='1463' class='m'>paredit-in-char-p</a>)
           (<a id='1466' tid='1465' class='m'>backward-sexp</a>))
          ((<a id='1468' tid='1467' class='m'>paredit-in-comment-p</a>)
           (<a id='1470' tid='1469' class='m'>error</a> <a id='1472' tid='1471' class='m'>&quot;No S-expression to raise in comment.&quot;</a>)))
    <a id='1474' tid='1473' class='m'>;; Select the S-expressions we want to raise in a buffer substring.
</a>    (<a id='1476' tid='1475' class='m'>let*</a> ((<a id='1478' tid='1477' class='m'>n</a> (<a id='1480' tid='1479' class='m'>prefix-numeric-value</a> <a id='1482' tid='1481' class='m'>argument</a>))
           (<a id='1484' tid='1483' class='m'>bound</a> (<a id='1486' tid='1485' class='m'>scan-sexps</a> (<a id='1488' tid='1487' class='m'>point</a>) <a id='1490' tid='1489' class='m'>n</a>))
           (<a id='1492' tid='1491' class='m'>sexps</a>
            (<a id='1494' tid='1493' class='m'>if</a> (<a id='1496' tid='1495' class='m'>&lt;</a> <a id='1498' tid='1497' class='m'>n</a> <a id='1500' tid='1499' class='m'>0</a>)
                (<a id='1502' tid='1501' class='m'>buffer-substring</a> <a id='1504' tid='1503' class='m'>bound</a> (<a id='1506' tid='1505' class='m'>paredit-point-at-sexp-end</a>))
                (<a id='1508' tid='1507' class='m'>buffer-substring</a> (<a id='1510' tid='1509' class='m'>paredit-point-at-sexp-start</a>) <a id='1512' tid='1511' class='m'>bound</a>))))
      <a id='1514' tid='1513' class='m'>;; Move up to the list we&#39;re raising those S-expressions out of and
</a>      <a id='1516' tid='1515' class='m'>;; delete it.
</a>      (<a id='1518' tid='1517' class='m'>backward-up-list</a>)
      (<a id='1520' tid='1519' class='m'>delete-region</a> (<a id='1522' tid='1521' class='m'>point</a>) (<a id='1524' tid='1523' class='m'>scan-sexps</a> (<a id='1526' tid='1525' class='m'>point</a>) <a id='1528' tid='1527' class='m'>1</a>))
      (<span class='i'>let*</span> ((<a id='1530' tid='1529' class='m'>indent-start</a> (<a id='1532' tid='1531' class='m'>point</a>))
             (<a id='1534' tid='1533' class='m'>indent-end</a> (<a id='1536' tid='1535' class='m'>save-excursion</a> (<a id='1538' tid='1537' class='m'>insert</a> <a id='1540' tid='1539' class='m'>sexps</a>) (<a id='1542' tid='1541' class='m'>point</a>))))
        <span class='i'>(indent-region indent-start indent-end nil)</span>))))

<span class='i'>;;; The effects of convolution on the surrounding whitespace are pretty
</span><span class='i'>;;; random.  If you have better suggestions, please let me know.
</span>
(<a id='2732' tid='2731' class='u'>defun</a> <a id='2734' tid='2733' class='u'>paredit-convolute-sexp</a> (<a id='2736' tid='2735' class='u'>&optional</a> <a id='2738' tid='2737' class='u'>n</a>)
  <a id='2740' tid='2739' class='u'>&quot;Convolute S-expressions.
Save the S-expressions preceding point and delete them.
Splice the S-expressions following point.
Wrap the enclosing list in a new list prefixed by the saved text.
With a prefix argument N, move up N lists before wrapping.&quot;</a>
  (<a id='2742' tid='2741' class='u'>interactive</a> <a id='2744' tid='2743' class='u'>&quot;p&quot;</a>)
  (<a id='2746' tid='2745' class='u'>paredit-lose-if-not-in-sexp</a> <a id='2748' tid='2747' class='u'>&#39;</a><a id='2750' tid='2749' class='u'>paredit-convolute-sexp</a>)
  <span class='i'>;; Make sure we can move up before destroying anything.
</span>  <span class='i'>(save-excursion (backward-up-list n) (backward-up-list))</span>
  (<a id='1544' tid='1543' class='m'>let</a> (<a id='1546' tid='1545' class='m'>open</a> <a id='1548' tid='1547' class='m'>close</a>)                     <a id='1550' tid='1549' class='m'>;++ Is this a good idea?
</a>    (<span class='i'>let</span> ((<a id='1552' tid='1551' class='m'>prefix</a>
           (<a id='1554' tid='1553' class='m'>let</a> ((<a id='1556' tid='1555' class='m'>end</a> (<a id='1558' tid='1557' class='m'>point</a>)))
             (<a id='1560' tid='1559' class='m'>paredit-ignore-sexp-errors</a>
               (<a id='1562' tid='1561' class='m'>while</a> (<a id='1564' tid='1563' class='m'>not</a> (<a id='1566' tid='1565' class='m'>bobp</a>)) (<a id='1568' tid='1567' class='m'>backward-sexp</a>)))
             (<span class='i'>prog1</span> <span class='i'>(buffer-substring (point) end)</span>
               <span class='i'>(backward-up-list)</span>
               (<a id='1570' tid='1569' class='m'>save-excursion</a> (<a id='1572' tid='1571' class='m'>forward-sexp</a>)
                               (<a id='1574' tid='1573' class='m'>setq</a> <a id='1576' tid='1575' class='m'>close</a> (<a id='1578' tid='1577' class='m'>char-before</a>))
                               (<a id='1580' tid='1579' class='m'>backward-delete-char</a> <a id='1582' tid='1581' class='m'>1</a>))
               <span class='i'>(setq open (char-after))</span>
               <span class='i'>(delete-region (point) end)</span>
               <span class='i'>;; I&#39;m not sure this makes sense...
</span>               <span class='i'>(if (not (eolp)) (just-one-space))</span>))))
      <span class='i'>(backward-up-list n)</span>
      (<a id='680' tid='679' class='m'>paredit-insert-pair</a> <a id='682' tid='681' class='m'>1</a> <a id='684' tid='683' class='m'>open</a> <a id='686' tid='685' class='m'>close</a> <a id='688' tid='687' class='m'>&#39;</a><a id='690' tid='689' class='m'>goto-char</a>)
      <span class='i'>(insert prefix)</span>
      <span class='i'>;; I&#39;m not sure this makes sense either...
</span>      <span class='i'>(if (not (eolp)) (just-one-space))</span>
      <span class='i'>(save-excursion
        (backward-up-list)
        (paredit-ignore-sexp-errors (indent-sexp)))</span>)))

(<a id='6222' tid='6221' class='u'>defun</a> <a id='6224' tid='6223' class='u'>paredit-splice-string</a> (<a id='6226' tid='6225' class='u'>argument</a>)
  (<a id='6228' tid='6227' class='u'>let</a> ((<a id='6230' tid='6229' class='u'>original-point</a> (<a id='6232' tid='6231' class='u'>point</a>))
        (<a id='6234' tid='6233' class='u'>start+end</a> (<a id='6236' tid='6235' class='u'>paredit-string-start+end-points</a>)))
    (<a id='6238' tid='6237' class='u'>let</a> ((<a id='6240' tid='6239' class='u'>start</a> (<a id='6242' tid='6241' class='u'>car</a> <a id='6244' tid='6243' class='u'>start+end</a>))
          (<a id='6246' tid='6245' class='u'>end</a> (<a id='6248' tid='6247' class='u'>cdr</a> <a id='6250' tid='6249' class='u'>start+end</a>)))
      <a id='6252' tid='6251' class='u'>;; START and END both lie before the respective quote
</a>      <a id='6254' tid='6253' class='u'>;; characters, which we want to delete; thus we increment START
</a>      <a id='6256' tid='6255' class='u'>;; by one to extract the string, and we increment END by one to
</a>      <a id='6258' tid='6257' class='u'>;; delete the string.
</a>      (<a id='6260' tid='6259' class='u'>let*</a> ((<a id='6262' tid='6261' class='u'>escaped-string</a>
              (<a id='6264' tid='6263' class='u'>cond</a> ((<a id='6266' tid='6265' class='u'>not</a> (<a id='6268' tid='6267' class='u'>consp</a> <a id='6270' tid='6269' class='u'>argument</a>))
                     (<a id='6272' tid='6271' class='u'>buffer-substring</a> (<a id='6274' tid='6273' class='u'>1+</a> <a id='6276' tid='6275' class='u'>start</a>) <a id='6278' tid='6277' class='u'>end</a>))
                    ((<a id='6280' tid='6279' class='u'>=</a> <a id='6282' tid='6281' class='u'>4</a> (<a id='6284' tid='6283' class='u'>car</a> <a id='6286' tid='6285' class='u'>argument</a>))
                     (<a id='6288' tid='6287' class='u'>buffer-substring</a> <a id='6290' tid='6289' class='u'>original-point</a> <a id='6292' tid='6291' class='u'>end</a>))
                    (<a id='6294' tid='6293' class='u'>t</a>
                     (<a id='6296' tid='6295' class='u'>buffer-substring</a> (<a id='6298' tid='6297' class='u'>1+</a> <a id='6300' tid='6299' class='u'>start</a>) <a id='6302' tid='6301' class='u'>original-point</a>))))
             (<a id='6304' tid='6303' class='u'>unescaped-string</a>
              (<a id='6306' tid='6305' class='u'>paredit-unescape-string</a> <a id='6308' tid='6307' class='u'>escaped-string</a>)))
        (<a id='6310' tid='6309' class='u'>if</a> (<a id='6312' tid='6311' class='u'>not</a> <a id='6314' tid='6313' class='u'>unescaped-string</a>)
            (<a id='6316' tid='6315' class='u'>error</a> <a id='6318' tid='6317' class='u'>&quot;Unspliceable string.&quot;</a>)
          (<a id='6320' tid='6319' class='u'>save-excursion</a>
            (<a id='6322' tid='6321' class='u'>goto-char</a> <a id='6324' tid='6323' class='u'>start</a>)
            (<a id='6326' tid='6325' class='u'>delete-region</a> <a id='6328' tid='6327' class='u'>start</a> (<a id='6330' tid='6329' class='u'>1+</a> <a id='6332' tid='6331' class='u'>end</a>))
            (<a id='6334' tid='6333' class='u'>insert</a> <a id='6336' tid='6335' class='u'>unescaped-string</a>))
          (<a id='6338' tid='6337' class='u'>if</a> (<a id='6340' tid='6339' class='u'>not</a> (<a id='6342' tid='6341' class='u'>and</a> (<a id='6344' tid='6343' class='u'>consp</a> <a id='6346' tid='6345' class='u'>argument</a>)
                        (<a id='6348' tid='6347' class='u'>=</a> <a id='6350' tid='6349' class='u'>4</a> (<a id='6352' tid='6351' class='u'>car</a> <a id='6354' tid='6353' class='u'>argument</a>))))
              (<a id='6356' tid='6355' class='u'>goto-char</a> (<a id='6358' tid='6357' class='u'>-</a> <a id='6360' tid='6359' class='u'>original-point</a> <a id='6362' tid='6361' class='u'>1</a>))))))))

(<a id='6482' tid='6481' class='u'>defun</a> <a id='6484' tid='6483' class='u'>paredit-unescape-string</a> (<a id='6486' tid='6485' class='u'>string</a>)
  (<span class='i'>with-temp-buffer</span>
    <span class='i'>(insert string)</span>
    <span class='i'>(goto-char (point-min))</span>
    (<a id='1584' tid='1583' class='m'>while</a> (<a id='1586' tid='1585' class='m'>and</a> (<a id='1588' tid='1587' class='m'>not</a> (<a id='1590' tid='1589' class='m'>eobp</a>))
                <a id='1592' tid='1591' class='m'>;; nil -&gt; no bound; t -&gt; no errors.
</a>                (<a id='1594' tid='1593' class='m'>search-forward</a> <a id='1596' tid='1595' class='m'>&quot;\\&quot;</a> <a id='1598' tid='1597' class='m'>nil</a> <a id='1600' tid='1599' class='m'>t</a>))
      (<a id='1602' tid='1601' class='m'>delete-char</a> <a id='1604' tid='1603' class='m'>-1</a>)
      (<a id='1606' tid='1605' class='m'>forward-char</a>))
    <span class='i'>(paredit-handle-sexp-errors
        (progn (scan-sexps (point-min) (point-max))
               (buffer-string))
      nil)</span>))

<span class='i'>;;;; Slurpage & Barfage
</span>
(<a id='3856' tid='3855' class='u'>defun</a> <a id='3858' tid='3857' class='u'>paredit-forward-slurp-sexp</a> ()
  <a id='3860' tid='3859' class='u'>&quot;Add the S-expression following the current list into that list
  by moving the closing delimiter.
Automatically reindent the newly slurped S-expression with respect to
  its new enclosing form.
If in a string, move the opening double-quote forward by one
  S-expression and escape any intervening characters as necessary,
  without altering any indentation or formatting.&quot;</a>
  (<a id='3862' tid='3861' class='u'>interactive</a>)
  (<a id='3864' tid='3863' class='u'>save-excursion</a>
    (<a id='3866' tid='3865' class='u'>cond</a> ((<a id='3868' tid='3867' class='u'>or</a> (<a id='3870' tid='3869' class='u'>paredit-in-comment-p</a>)
               (<a id='3872' tid='3871' class='u'>paredit-in-char-p</a>))
           (<a id='3874' tid='3873' class='u'>error</a> <a id='3876' tid='3875' class='u'>&quot;Invalid context for slurping S-expressions.&quot;</a>))
          ((<a id='3878' tid='3877' class='u'>paredit-in-string-p</a>)
           (<a id='3880' tid='3879' class='u'>paredit-forward-slurp-into-string</a>))
          (<a id='3882' tid='3881' class='u'>t</a>
           (<a id='3884' tid='3883' class='u'>paredit-forward-slurp-into-list</a>)))))

(<a id='3806' tid='3805' class='u'>defun</a> <a id='3808' tid='3807' class='u'>paredit-forward-slurp-into-list</a> ()
  (<a id='3810' tid='3809' class='u'>up-list</a>)                             <a id='3812' tid='3811' class='u'>; Up to the end of the list to
</a>  (<span class='i'>let</span> <span class='i'>((close (char-before)))</span>          <span class='i'>;   save and delete the closing
</span>    <span class='i'>(backward-delete-char 1)</span>            <span class='i'>;   delimiter.
</span>    (<span class='i'>let</span> <span class='i'>((start (point)))</span>
      (<a id='1608' tid='1607' class='m'>catch</a> <a id='1610' tid='1609' class='m'>&#39;</a><a id='1612' tid='1611' class='m'>return</a>                    <a id='1614' tid='1613' class='m'>; Go to the end of the desired
</a>        (<a id='1616' tid='1615' class='m'>while</a> <a id='1618' tid='1617' class='m'>t</a>                        <a id='1620' tid='1619' class='m'>;   S-expression, going up a
</a>          (<span class='i'>paredit-handle-sexp-errors</span>   <span class='i'>;   list if it&#39;s not in this,
</span>              <span class='i'>(progn (forward-sexp) (throw &#39;return nil))</span>
            <span class='i'>(up-list)</span>
            (<a id='1622' tid='1621' class='m'>setq</a> <a id='1624' tid='1623' class='m'>close</a>                 <a id='1626' tid='1625' class='m'>; adjusting for mixed
</a>                  (<a id='1628' tid='1627' class='m'>prog1</a> (<a id='1630' tid='1629' class='m'>char-before</a>)  <a id='1632' tid='1631' class='m'>;   delimiters as necessary,
</a>                    (<a id='1634' tid='1633' class='m'>backward-delete-char</a> <a id='1636' tid='1635' class='m'>1</a>)
                    (<a id='1638' tid='1637' class='m'>insert</a> <a id='1640' tid='1639' class='m'>close</a>))))))
      <span class='i'>(insert close)</span>                    <span class='i'>; to insert that delimiter.
</span>      <span class='i'>(indent-region start (point) nil)</span>)))

(<a id='3814' tid='3813' class='u'>defun</a> <a id='3816' tid='3815' class='u'>paredit-forward-slurp-into-string</a> ()
  (<a id='3818' tid='3817' class='u'>goto-char</a> (<a id='3820' tid='3819' class='u'>1+</a> (<a id='3822' tid='3821' class='u'>cdr</a> (<a id='3824' tid='3823' class='u'>paredit-string-start+end-points</a>))))
  <a id='3826' tid='3825' class='u'>;; Signal any errors that we might get first, before mucking with the
</a>  <a id='3828' tid='3827' class='u'>;; buffer&#39;s contents.
</a>  (<a id='3830' tid='3829' class='u'>save-excursion</a> (<a id='3832' tid='3831' class='u'>forward-sexp</a>))
  (<a id='3834' tid='3833' class='u'>let</a> ((<a id='3836' tid='3835' class='u'>close</a> (<a id='3838' tid='3837' class='u'>char-before</a>)))
    (<a id='3840' tid='3839' class='u'>backward-delete-char</a> <a id='3842' tid='3841' class='u'>1</a>)
    (<a id='3844' tid='3843' class='u'>paredit-forward-for-quote</a> (<a id='3846' tid='3845' class='u'>save-excursion</a> (<a id='3848' tid='3847' class='u'>forward-sexp</a>) (<a id='3850' tid='3849' class='u'>point</a>)))
    (<a id='3852' tid='3851' class='u'>insert</a> <a id='3854' tid='3853' class='u'>close</a>)))

(<a id='3218' tid='3217' class='u'>defun</a> <a id='3220' tid='3219' class='u'>paredit-forward-barf-sexp</a> ()
  <a id='3222' tid='3221' class='u'>&quot;Remove the last S-expression in the current list from that list
  by moving the closing delimiter.
Automatically reindent the newly barfed S-expression with respect to
  its new enclosing form.&quot;</a>
  (<a id='3224' tid='3223' class='u'>interactive</a>)
  (<a id='3226' tid='3225' class='u'>paredit-lose-if-not-in-sexp</a> <a id='3228' tid='3227' class='u'>&#39;</a><a id='3230' tid='3229' class='u'>paredit-forward-barf-sexp</a>)
  <span class='i'>(save-excursion
    (up-list)                           ; Up to the end of the list to
    (let ((close (char-before)))        ;   save and delete the closing
      (backward-delete-char 1)          ;   delimiter.
      (paredit-ignore-sexp-errors       ; Go back to where we want to
        (backward-sexp))                ;   insert the delimiter.
      (paredit-skip-whitespace nil)     ; Skip leading whitespace.
      (cond ((bobp)
             (error &quot;Barfing all subexpressions with no open-paren?&quot;))
            ((paredit-in-comment-p)     ; Don&#39;t put the close-paren in
             (newline)))                ;   a comment.
      (insert close))
    ;; Reindent all of the newly barfed S-expressions.
    (paredit-forward-and-indent))</span>)

(<a id='2512' tid='2511' class='u'>defun</a> <a id='2514' tid='2513' class='u'>paredit-backward-slurp-sexp</a> ()
  <a id='2516' tid='2515' class='u'>&quot;Add the S-expression preceding the current list into that list
  by moving the closing delimiter.
Automatically reindent the whole form into which new S-expression was
  slurped.
If in a string, move the opening double-quote backward by one
  S-expression and escape any intervening characters as necessary,
  without altering any indentation or formatting.&quot;</a>
  (<a id='2518' tid='2517' class='u'>interactive</a>)
  (<a id='2520' tid='2519' class='u'>save-excursion</a>
    (<a id='2522' tid='2521' class='u'>cond</a> ((<a id='2524' tid='2523' class='u'>or</a> (<a id='2526' tid='2525' class='u'>paredit-in-comment-p</a>)
               (<a id='2528' tid='2527' class='u'>paredit-in-char-p</a>))
           (<a id='2530' tid='2529' class='u'>error</a> <a id='2532' tid='2531' class='u'>&quot;Invalid context for slurping S-expressions.&quot;</a>))
          ((<a id='2534' tid='2533' class='u'>paredit-in-string-p</a>)
           (<a id='2536' tid='2535' class='u'>paredit-backward-slurp-into-string</a>))
          (<a id='2538' tid='2537' class='u'>t</a>
           (<a id='2540' tid='2539' class='u'>paredit-backward-slurp-into-list</a>)))))

(<a id='2396' tid='2395' class='u'>defun</a> <a id='2398' tid='2397' class='u'>paredit-backward-slurp-into-list</a> ()
  (<a id='2400' tid='2399' class='u'>backward-up-list</a>)
  (<a id='2402' tid='2401' class='u'>let</a> ((<a id='2404' tid='2403' class='u'>open</a> (<a id='2406' tid='2405' class='u'>char-after</a>)))
    (<a id='2408' tid='2407' class='u'>delete-char</a> <a id='2410' tid='2409' class='u'>1</a>)
    (<a id='2412' tid='2411' class='u'>catch</a> <a id='2414' tid='2413' class='u'>&#39;</a><a id='2416' tid='2415' class='u'>return</a>
      (<a id='2418' tid='2417' class='u'>while</a> <a id='2420' tid='2419' class='u'>t</a>
        (<a id='2422' tid='2421' class='u'>paredit-handle-sexp-errors</a>
            (<a id='2424' tid='2423' class='u'>progn</a> (<a id='2426' tid='2425' class='u'>backward-sexp</a>) (<a id='2428' tid='2427' class='u'>throw</a> <a id='2430' tid='2429' class='u'>&#39;</a><a id='2432' tid='2431' class='u'>return</a> <a id='2434' tid='2433' class='u'>nil</a>))
          (<a id='2436' tid='2435' class='u'>backward-up-list</a>)
          (<a id='2438' tid='2437' class='u'>setq</a> <a id='2440' tid='2439' class='u'>open</a>
                (<a id='2442' tid='2441' class='u'>prog1</a> (<a id='2444' tid='2443' class='u'>char-after</a>)
                  (<a id='2446' tid='2445' class='u'>save-excursion</a> (<a id='2448' tid='2447' class='u'>insert</a> <a id='2450' tid='2449' class='u'>open</a>) (<a id='2452' tid='2451' class='u'>delete-char</a> <a id='2454' tid='2453' class='u'>1</a>)))))))
    (<a id='2456' tid='2455' class='u'>insert</a> <a id='2458' tid='2457' class='u'>open</a>))
  <a id='2460' tid='2459' class='u'>;; Reindent the line at the beginning of wherever we inserted the
</a>  <a id='2462' tid='2461' class='u'>;; opening delimiter, and then indent the whole S-expression.
</a>  (<a id='2464' tid='2463' class='u'>backward-up-list</a>)
  (<a id='2466' tid='2465' class='u'>lisp-indent-line</a>)
  (<a id='2468' tid='2467' class='u'>indent-sexp</a>))

(<a id='2470' tid='2469' class='u'>defun</a> <a id='2472' tid='2471' class='u'>paredit-backward-slurp-into-string</a> ()
  (<a id='2474' tid='2473' class='u'>goto-char</a> (<a id='2476' tid='2475' class='u'>car</a> (<a id='2478' tid='2477' class='u'>paredit-string-start+end-points</a>)))
  <a id='2480' tid='2479' class='u'>;; Signal any errors that we might get first, before mucking with the
</a>  <a id='2482' tid='2481' class='u'>;; buffer&#39;s contents.
</a>  (<a id='2484' tid='2483' class='u'>save-excursion</a> (<a id='2486' tid='2485' class='u'>backward-sexp</a>))
  (<a id='2488' tid='2487' class='u'>let</a> ((<a id='2490' tid='2489' class='u'>open</a> (<a id='2492' tid='2491' class='u'>char-after</a>))
        (<a id='2494' tid='2493' class='u'>target</a> (<a id='2496' tid='2495' class='u'>point</a>)))
    (<a id='2498' tid='2497' class='u'>delete-char</a> <a id='2500' tid='2499' class='u'>1</a>)
    (<a id='2502' tid='2501' class='u'>backward-sexp</a>)
    (<a id='2504' tid='2503' class='u'>insert</a> <a id='2506' tid='2505' class='u'>open</a>)
    (<a id='2508' tid='2507' class='u'>paredit-forward-for-quote</a> <a id='2510' tid='2509' class='u'>target</a>)))

(<a id='2034' tid='2033' class='u'>defun</a> <a id='2036' tid='2035' class='u'>paredit-backward-barf-sexp</a> ()
  <a id='2038' tid='2037' class='u'>&quot;Remove the first S-expression in the current list from that list
  by moving the closing delimiter.
Automatically reindent the barfed S-expression and the form from which
  it was barfed.&quot;</a>
  (<a id='2040' tid='2039' class='u'>interactive</a>)
  (<a id='2042' tid='2041' class='u'>paredit-lose-if-not-in-sexp</a> <a id='2044' tid='2043' class='u'>&#39;</a><a id='2046' tid='2045' class='u'>paredit-backward-barf-sexp</a>)
  (<a id='2048' tid='2047' class='u'>save-excursion</a>
    (<a id='2050' tid='2049' class='u'>backward-up-list</a>)
    (<a id='2052' tid='2051' class='u'>let</a> ((<a id='2054' tid='2053' class='u'>open</a> (<a id='2056' tid='2055' class='u'>char-after</a>)))
      (<a id='2058' tid='2057' class='u'>delete-char</a> <a id='2060' tid='2059' class='u'>1</a>)
      (<a id='2062' tid='2061' class='u'>paredit-ignore-sexp-errors</a>
        (<a id='2064' tid='2063' class='u'>paredit-forward-and-indent</a>))
      (<a id='2066' tid='2065' class='u'>while</a> (<a id='2068' tid='2067' class='u'>progn</a> (<a id='2070' tid='2069' class='u'>paredit-skip-whitespace</a> <a id='2072' tid='2071' class='u'>t</a>)
                    (<a id='2074' tid='2073' class='u'>eq</a> (<a id='2076' tid='2075' class='u'>char-after</a>) <a id='2078' tid='2077' class='u'>?\;</a> ))
        (<a id='2080' tid='2079' class='u'>forward-line</a> <a id='2082' tid='2081' class='u'>1</a>))
      (<a id='2084' tid='2083' class='u'>if</a> (<a id='2086' tid='2085' class='u'>eobp</a>)
          (<a id='2088' tid='2087' class='u'>error</a> <a id='2090' tid='2089' class='u'>&quot;Barfing all subexpressions with no close-paren?&quot;</a>))
      <a id='2092' tid='2091' class='u'>;** Don&#39;t use `insert&#39; here.  Consider, e.g., barfing from
</a>      <a id='2094' tid='2093' class='u'>;**   (foo|)
</a>      <a id='2096' tid='2095' class='u'>;** and how `save-excursion&#39; works.
</a>      (<a id='2098' tid='2097' class='u'>insert-before-markers</a> <a id='2100' tid='2099' class='u'>open</a>))
    (<a id='2102' tid='2101' class='u'>backward-up-list</a>)
    (<a id='2104' tid='2103' class='u'>lisp-indent-line</a>)
    (<a id='2106' tid='2105' class='u'>indent-sexp</a>)))

<span class='i'>;;;; Splitting & Joining
</span>
(<a id='6364' tid='6363' class='u'>defun</a> <a id='6366' tid='6365' class='u'>paredit-split-sexp</a> ()
  <a id='6368' tid='6367' class='u'>&quot;Split the list or string the point is on into two.&quot;</a>
  (<a id='6370' tid='6369' class='u'>interactive</a>)
  (<a id='6372' tid='6371' class='u'>cond</a> ((<a id='6374' tid='6373' class='u'>paredit-in-string-p</a>)
         (<a id='6376' tid='6375' class='u'>insert</a> <a id='6378' tid='6377' class='u'>&quot;\&quot;&quot;</a>)
         (<a id='6380' tid='6379' class='u'>save-excursion</a> (<a id='6382' tid='6381' class='u'>insert</a> <a id='6384' tid='6383' class='u'>&quot; \&quot;&quot;</a>)))
        ((<a id='6386' tid='6385' class='u'>or</a> (<a id='6388' tid='6387' class='u'>paredit-in-comment-p</a>)
             (<a id='6390' tid='6389' class='u'>paredit-in-char-p</a>))
         (<a id='6392' tid='6391' class='u'>error</a> <a id='6394' tid='6393' class='u'>&quot;Invalid context for splitting S-expression.&quot;</a>))
        (<a id='6396' tid='6395' class='u'>t</a> (<a id='6398' tid='6397' class='u'>let</a> ((<a id='6400' tid='6399' class='u'>open</a>  (<a id='6402' tid='6401' class='u'>save-excursion</a> (<a id='6404' tid='6403' class='u'>backward-up-list</a>)
                                        (<a id='6406' tid='6405' class='u'>char-after</a>)))
                 (<a id='6408' tid='6407' class='u'>close</a> (<a id='6410' tid='6409' class='u'>save-excursion</a> (<a id='6412' tid='6411' class='u'>up-list</a>)
                                        (<a id='6414' tid='6413' class='u'>char-before</a>))))
             (<a id='6416' tid='6415' class='u'>delete-horizontal-space</a>)
             (<a id='6418' tid='6417' class='u'>insert</a> <a id='6420' tid='6419' class='u'>close</a>)
             (<a id='6422' tid='6421' class='u'>save-excursion</a> (<a id='6424' tid='6423' class='u'>insert</a> <a id='6426' tid='6425' class='u'>?\ </a>)
                             (<a id='6428' tid='6427' class='u'>insert</a> <a id='6430' tid='6429' class='u'>open</a>)
                             (<a id='6432' tid='6431' class='u'>backward-char</a>)
                             (<a id='6434' tid='6433' class='u'>indent-sexp</a>))))))

(<a id='4478' tid='4477' class='u'>defun</a> <a id='4480' tid='4479' class='u'>paredit-join-sexps</a> ()
  <a id='4482' tid='4481' class='u'>&quot;Join the S-expressions adjacent on either side of the point.
Both must be lists, strings, or atoms; error if there is a mismatch.&quot;</a>
  (<a id='4484' tid='4483' class='u'>interactive</a>)
  <a id='4486' tid='4485' class='u'>;++ How ought this to handle comments intervening symbols or strings?
</a>  (<a id='1642' tid='1641' class='m'>save-excursion</a>
    (<a id='1644' tid='1643' class='m'>if</a> (<a id='1646' tid='1645' class='m'>or</a> (<a id='1648' tid='1647' class='m'>paredit-in-comment-p</a>)
            (<a id='1650' tid='1649' class='m'>paredit-in-string-p</a>)
            (<a id='1652' tid='1651' class='m'>paredit-in-char-p</a>))
        (<a id='1654' tid='1653' class='m'>error</a> <a id='1656' tid='1655' class='m'>&quot;Invalid context for joining S-expressions.&quot;</a>)
      (<a id='1658' tid='1657' class='m'>let</a> ((<a id='1660' tid='1659' class='m'>left-point</a>  (<a id='1662' tid='1661' class='m'>paredit-point-at-sexp-end</a>))
            (<a id='1664' tid='1663' class='m'>right-point</a> (<a id='1666' tid='1665' class='m'>paredit-point-at-sexp-start</a>)))
        (<a id='1668' tid='1667' class='m'>let</a> ((<a id='1670' tid='1669' class='m'>left-char</a> (<a id='1672' tid='1671' class='m'>char-before</a> <a id='1674' tid='1673' class='m'>left-point</a>))
              (<a id='1676' tid='1675' class='m'>right-char</a> (<a id='1678' tid='1677' class='m'>char-after</a> <a id='1680' tid='1679' class='m'>right-point</a>)))
          (<a id='1682' tid='1681' class='m'>let</a> ((<a id='1684' tid='1683' class='m'>left-syntax</a> (<a id='1686' tid='1685' class='m'>char-syntax</a> <a id='1688' tid='1687' class='m'>left-char</a>))
                (<a id='1690' tid='1689' class='m'>right-syntax</a> (<a id='1692' tid='1691' class='m'>char-syntax</a> <a id='1694' tid='1693' class='m'>right-char</a>)))
            (<span class='i'>cond</span> <span class='i'>((&lt; right-point left-point)
                   (error &quot;Can&#39;t join a datum with itself.&quot;))</span>
                  ((<a id='1696' tid='1695' class='m'>and</a> (<a id='1698' tid='1697' class='m'>eq</a> <a id='1700' tid='1699' class='m'>left-syntax</a>  <a id='1702' tid='1701' class='m'>?\)</a> )
                        (<a id='1704' tid='1703' class='m'>eq</a> <a id='1706' tid='1705' class='m'>right-syntax</a> <a id='1708' tid='1707' class='m'>?\(</a> )
                        (<a id='1710' tid='1709' class='m'>eq</a> <a id='1712' tid='1711' class='m'>left-char</a> (<a id='1714' tid='1713' class='m'>matching-paren</a> <a id='1716' tid='1715' class='m'>right-char</a>))
                        (<a id='1718' tid='1717' class='m'>eq</a> <a id='1720' tid='1719' class='m'>right-char</a> (<a id='1722' tid='1721' class='m'>matching-paren</a> <a id='1724' tid='1723' class='m'>left-char</a>)))
                   <span class='i'>;; Leave intermediate formatting alone.
</span>                   <span class='i'>(goto-char right-point)</span>
                   <span class='i'>(delete-char 1)</span>
                   <span class='i'>(goto-char left-point)</span>
                   <span class='i'>(backward-delete-char 1)</span>
                   <span class='i'>;; Heuristic kludge: (foo)(bar) =&gt; (foo bar).
</span>                   <span class='i'>(if (and (= left-point right-point)
                            (not (or (eq ?\  (char-syntax (char-before)))
                                     (eq ?\  (char-syntax (char-after))))))
                       (insert ?\  ))</span>
                   <span class='i'>(backward-up-list)</span>
                   <span class='i'>(indent-sexp)</span>)
                  ((<a id='692' tid='691' class='m'>and</a> (<a id='694' tid='693' class='m'>eq</a> <a id='696' tid='695' class='m'>left-syntax</a>  <a id='698' tid='697' class='m'>?\&quot;</a> )
                        (<a id='700' tid='699' class='m'>eq</a> <a id='702' tid='701' class='m'>right-syntax</a> <a id='704' tid='703' class='m'>?\&quot;</a> ))
                   <a id='706' tid='705' class='m'>;; Delete any intermediate formatting.
</a>                   (<a id='708' tid='707' class='m'>delete-region</a> (<a id='710' tid='709' class='m'>1-</a> <a id='712' tid='711' class='m'>left-point</a>) (<a id='714' tid='713' class='m'>1+</a> <a id='716' tid='715' class='m'>right-point</a>)))
                  ((<a id='496' tid='495' class='m'>and</a> (<a id='498' tid='497' class='m'>memq</a> <a id='500' tid='499' class='m'>left-syntax</a>  <a id='502' tid='501' class='m'>&#39;</a>(<a id='504' tid='503' class='m'>?w</a> <a id='506' tid='505' class='m'>?_</a>)) <a id='508' tid='507' class='m'>; Word or symbol
</a>                        (<a id='510' tid='509' class='m'>memq</a> <a id='512' tid='511' class='m'>right-syntax</a> <a id='514' tid='513' class='m'>&#39;</a>(<a id='516' tid='515' class='m'>?w</a> <a id='518' tid='517' class='m'>?_</a>)))
                   (<a id='520' tid='519' class='m'>delete-region</a> <a id='522' tid='521' class='m'>left-point</a> <a id='524' tid='523' class='m'>right-point</a>))
                  <span class='i'>(t
                   (error &quot;Mismatched S-expressions to join.&quot;))</span>)))))))

<span class='i'>;;;; Variations on the Lurid Theme
</span>
<span class='i'>;;; I haven&#39;t the imagination to concoct clever names for these.
</span>
(<a id='1810' tid='1809' class='u'>defun</a> <a id='1812' tid='1811' class='u'>paredit-add-to-previous-list</a> ()
  <a id='1814' tid='1813' class='u'>&quot;Add the S-expression following point to the list preceding point.&quot;</a>
  (<a id='1816' tid='1815' class='u'>interactive</a>)
  (<a id='1818' tid='1817' class='u'>paredit-lose-if-not-in-sexp</a> <a id='1820' tid='1819' class='u'>&#39;</a><a id='1822' tid='1821' class='u'>paredit-add-to-previous-list</a>)
  (<a id='1824' tid='1823' class='u'>save-excursion</a>
    (<a id='1826' tid='1825' class='u'>backward-down-list</a>)
    (<a id='1828' tid='1827' class='u'>paredit-forward-slurp-sexp</a>)))

(<a id='1790' tid='1789' class='u'>defun</a> <a id='1792' tid='1791' class='u'>paredit-add-to-next-list</a> ()
  <a id='1794' tid='1793' class='u'>&quot;Add the S-expression preceding point to the list following point.
If no S-expression precedes point, move up the tree until one does.&quot;</a>
  (<a id='1796' tid='1795' class='u'>interactive</a>)
  (<a id='1798' tid='1797' class='u'>paredit-lose-if-not-in-sexp</a> <a id='1800' tid='1799' class='u'>&#39;</a><a id='1802' tid='1801' class='u'>paredit-add-to-next-list</a>)
  (<a id='1804' tid='1803' class='u'>save-excursion</a>
    (<a id='1806' tid='1805' class='u'>down-list</a>)
    (<a id='1808' tid='1807' class='u'>paredit-backward-slurp-sexp</a>)))

(<a id='4520' tid='4519' class='u'>defun</a> <a id='4522' tid='4521' class='u'>paredit-join-with-previous-list</a> ()
  <a id='4524' tid='4523' class='u'>&quot;Join the list the point is on with the previous list in the buffer.&quot;</a>
  (<a id='4526' tid='4525' class='u'>interactive</a>)
  (<a id='4528' tid='4527' class='u'>paredit-lose-if-not-in-sexp</a> <a id='4530' tid='4529' class='u'>&#39;</a><a id='4532' tid='4531' class='u'>paredit-join-with-previous-list</a>)
  (<a id='4534' tid='4533' class='u'>save-excursion</a>
    (<a id='4536' tid='4535' class='u'>while</a> (<a id='4538' tid='4537' class='u'>paredit-handle-sexp-errors</a> (<a id='4540' tid='4539' class='u'>save-excursion</a> (<a id='4542' tid='4541' class='u'>backward-sexp</a>) <a id='4544' tid='4543' class='u'>nil</a>)
             (<a id='4546' tid='4545' class='u'>backward-up-list</a>)
             <a id='4548' tid='4547' class='u'>t</a>))
    (<a id='4550' tid='4549' class='u'>paredit-join-sexps</a>)))

(<a id='4488' tid='4487' class='u'>defun</a> <a id='4490' tid='4489' class='u'>paredit-join-with-next-list</a> ()
  <a id='4492' tid='4491' class='u'>&quot;Join the list the point is on with the next list in the buffer.&quot;</a>
  (<a id='4494' tid='4493' class='u'>interactive</a>)
  (<a id='4496' tid='4495' class='u'>paredit-lose-if-not-in-sexp</a> <a id='4498' tid='4497' class='u'>&#39;</a><a id='4500' tid='4499' class='u'>paredit-join-with-next-list</a>)
  (<a id='4502' tid='4501' class='u'>save-excursion</a>
    (<a id='4504' tid='4503' class='u'>while</a> (<a id='4506' tid='4505' class='u'>paredit-handle-sexp-errors</a> (<a id='4508' tid='4507' class='u'>save-excursion</a> (<a id='4510' tid='4509' class='u'>forward-sexp</a>) <a id='4512' tid='4511' class='u'>nil</a>)
             (<a id='4514' tid='4513' class='u'>up-list</a>)
             <a id='4516' tid='4515' class='u'>t</a>))
    (<a id='4518' tid='4517' class='u'>paredit-join-sexps</a>)))

<span class='i'>;;;; Utilities
</span>
(<a id='4106' tid='4105' class='u'>defun</a> <a id='4108' tid='4107' class='u'>paredit-in-string-escape-p</a> ()
  <a id='4110' tid='4109' class='u'>&quot;True if the point is on a character escape of a string.
This is true only if the character is preceded by an odd number of
  backslashes.
This assumes that `paredit-in-string-p&#39; has already returned true.&quot;</a>
  (<a id='4112' tid='4111' class='u'>let</a> ((<a id='4114' tid='4113' class='u'>oddp</a> <a id='4116' tid='4115' class='u'>nil</a>))
    (<a id='4118' tid='4117' class='u'>save-excursion</a>
      (<a id='4120' tid='4119' class='u'>while</a> (<a id='4122' tid='4121' class='u'>eq</a> (<a id='4124' tid='4123' class='u'>char-before</a>) <a id='4126' tid='4125' class='u'>?\\</a> )
        (<a id='4128' tid='4127' class='u'>setq</a> <a id='4130' tid='4129' class='u'>oddp</a> (<a id='4132' tid='4131' class='u'>not</a> <a id='4134' tid='4133' class='u'>oddp</a>))
        (<a id='4136' tid='4135' class='u'>backward-char</a>)))
    <a id='4138' tid='4137' class='u'>oddp</a>))

(<a id='4074' tid='4073' class='u'>defun</a> <a id='4076' tid='4075' class='u'>paredit-in-char-p</a> <span class='i'>(&optional position)</span>
  <span class='i'>&quot;True if point is on a character escape outside a string.&quot;</span>
  <span class='i'>(save-excursion
    (goto-char (or position (point)))
    (paredit-in-string-escape-p))</span>)

(<a id='4166' tid='4165' class='u'>defun</a> <a id='4168' tid='4167' class='u'>paredit-indent-sexps</a> ()
  <a id='4170' tid='4169' class='u'>&quot;If in a list, indent all following S-expressions in the list.&quot;</a>
  (<span class='i'>let*</span> ((<a id='1726' tid='1725' class='m'>start</a> (<a id='1728' tid='1727' class='m'>point</a>))
         (<a id='1730' tid='1729' class='m'>end</a> (<a id='1732' tid='1731' class='m'>paredit-handle-sexp-errors</a> (<a id='1734' tid='1733' class='m'>progn</a> (<a id='1736' tid='1735' class='m'>up-list</a>) (<a id='1738' tid='1737' class='m'>point</a>)) <a id='1740' tid='1739' class='m'>nil</a>)))
    <span class='i'>(if end
        (indent-region start end nil))</span>))

(<a id='3212' tid='3211' class='u'>defun</a> <a id='3214' tid='3213' class='u'>paredit-forward-and-indent</a> ()
  <a id='3216' tid='3215' class='u'>&quot;Move forward an S-expression, indenting it with `indent-region&#39;.&quot;</a>
  <span class='i'>(let ((start (point)))
    (forward-sexp)
    (indent-region start (point) nil))</span>)

(<a id='5996' tid='5995' class='u'>defun</a> <a id='5998' tid='5997' class='u'>paredit-skip-whitespace</a> (<a id='6000' tid='5999' class='u'>trailing-p</a> <a id='6002' tid='6001' class='u'>&optional</a> <a id='6004' tid='6003' class='u'>limit</a>)
  <a id='6006' tid='6005' class='u'>&quot;Skip past any whitespace, or until the point LIMIT is reached.
If TRAILING-P is nil, skip leading whitespace; otherwise, skip trailing
  whitespace.&quot;</a>
  (<a id='6008' tid='6007' class='u'>funcall</a> (<a id='6010' tid='6009' class='u'>if</a> <a id='6012' tid='6011' class='u'>trailing-p</a> <a id='6014' tid='6013' class='u'>&#39;</a><a id='6016' tid='6015' class='u'>skip-chars-forward</a> <a id='6018' tid='6017' class='u'>&#39;</a><a id='6020' tid='6019' class='u'>skip-chars-backward</a>)
           <a id='6022' tid='6021' class='u'>&quot; \t\n&quot;</a>  <a id='6024' tid='6023' class='u'>; This should skip using the syntax table, but LF
</a>           <a id='6026' tid='6025' class='u'>limit</a>))    <span class='i'>; is a comment end, not newline, in Lisp mode.
</span>
(<a id='7464' tid='7463' class='u'>defalias</a> <a id='7466' tid='7465' class='u'>&#39;</a><a id='7468' tid='7467' class='u'>paredit-region-active-p</a>
  (<a id='7470' tid='7469' class='u'>xcond</a> ((<a id='7472' tid='7471' class='u'>paredit-xemacs-p</a>) <a id='7474' tid='7473' class='u'>&#39;</a><a id='7476' tid='7475' class='u'>region-active-p</a>)
         ((<a id='7478' tid='7477' class='u'>paredit-gnu-emacs-p</a>)
          (<a id='7480' tid='7479' class='u'>lambda</a> ()
            (<a id='7482' tid='7481' class='u'>and</a> <a id='7484' tid='7483' class='u'>mark-active</a> <a id='7486' tid='7485' class='u'>transient-mark-mode</a>)))))

(<a id='3956' tid='3955' class='u'>defun</a> <a id='3958' tid='3957' class='u'>paredit-hack-kill-region</a> (<a id='3960' tid='3959' class='u'>start</a> <a id='3962' tid='3961' class='u'>end</a>)
  <a id='3964' tid='3963' class='u'>&quot;Kill the region between START and END.
Do not append to any current kill, and
 do not let the next kill append to this one.&quot;</a>
  (<a id='3966' tid='3965' class='u'>interactive</a> <a id='3968' tid='3967' class='u'>&quot;r&quot;</a>)                     <a id='3970' tid='3969' class='u'>;Eh, why not?
</a>  <a id='3972' tid='3971' class='u'>;; KILL-REGION sets THIS-COMMAND to tell the next kill that the last
</a>  <a id='3974' tid='3973' class='u'>;; command was a kill.  It also checks LAST-COMMAND to see whether it
</a>  <a id='3976' tid='3975' class='u'>;; should append.  If we bind these locally, any modifications to
</a>  <a id='3978' tid='3977' class='u'>;; THIS-COMMAND will be masked, and it will not see LAST-COMMAND to
</a>  <a id='3980' tid='3979' class='u'>;; indicate that it should append.
</a>  (<a id='3982' tid='3981' class='u'>let</a> ((<a id='3984' tid='3983' class='u'>this-command</a> <a id='3986' tid='3985' class='u'>nil</a>)
        (<a id='3988' tid='3987' class='u'>last-command</a> <a id='3990' tid='3989' class='u'>nil</a>))
    (<a id='3992' tid='3991' class='u'>kill-region</a> <a id='3994' tid='3993' class='u'>start</a> <a id='3996' tid='3995' class='u'>end</a>)))

<a id='7488' tid='7487' class='u'>;;;;; S-expression Parsing Utilities
</a>
<a id='7490' tid='7489' class='u'>;++ These routines redundantly traverse S-expressions a great deal.
</a><a id='7492' tid='7491' class='u'>;++ If performance issues arise, this whole section will probably have
</a><a id='7494' tid='7493' class='u'>;++ to be refactored to preserve the state longer, like paredit.scm
</a><a id='7496' tid='7495' class='u'>;++ does, rather than to traverse the definition N times for every key
</a><a id='7498' tid='7497' class='u'>;++ stroke as it presently does.
</a>
(<a id='2932' tid='2931' class='u'>defun</a> <a id='2934' tid='2933' class='u'>paredit-current-parse-state</a> ()
  <a id='2936' tid='2935' class='u'>&quot;Return parse state of point from beginning of defun.&quot;</a>
  (<a id='2938' tid='2937' class='u'>let</a> ((<a id='2940' tid='2939' class='u'>point</a> (<a id='2942' tid='2941' class='u'>point</a>)))
    (<a id='2944' tid='2943' class='u'>beginning-of-defun</a>)
    <a id='2946' tid='2945' class='u'>;; Calling PARSE-PARTIAL-SEXP will advance the point to its second
</a>    <a id='2948' tid='2947' class='u'>;; argument (unless parsing stops due to an error, but we assume it
</a>    <a id='2950' tid='2949' class='u'>;; won&#39;t in paredit-mode).
</a>    (<a id='2952' tid='2951' class='u'>parse-partial-sexp</a> (<a id='2954' tid='2953' class='u'>point</a>) <a id='2956' tid='2955' class='u'>point</a>)))

(<a id='4140' tid='4139' class='u'>defun</a> <a id='4142' tid='4141' class='u'>paredit-in-string-p</a> (<a id='4144' tid='4143' class='u'>&optional</a> <a id='4146' tid='4145' class='u'>state</a>)
  <a id='4148' tid='4147' class='u'>&quot;True if the parse state is within a double-quote-delimited string.
If no parse state is supplied, compute one from the beginning of the
  defun to the point.&quot;</a>
  <a id='4150' tid='4149' class='u'>;; 3. non-nil if inside a string (the terminator character, really)
</a>  (<a id='4152' tid='4151' class='u'>and</a> (<a id='4154' tid='4153' class='u'>nth</a> <a id='4156' tid='4155' class='u'>3</a> (<a id='4158' tid='4157' class='u'>or</a> <a id='4160' tid='4159' class='u'>state</a> (<a id='4162' tid='4161' class='u'>paredit-current-parse-state</a>)))
       <a id='4164' tid='4163' class='u'>t</a>))

(<a id='6436' tid='6435' class='u'>defun</a> <a id='6438' tid='6437' class='u'>paredit-string-start+end-points</a> (<a id='6440' tid='6439' class='u'>&optional</a> <a id='6442' tid='6441' class='u'>state</a>)
  <a id='6444' tid='6443' class='u'>&quot;Return a cons of the points of open and close quotes of the string.
The string is determined from the parse state STATE, or the parse state
  from the beginning of the defun to the point.
This assumes that `paredit-in-string-p&#39; has already returned true, i.e.
  that the point is already within a string.&quot;</a>
  (<a id='6446' tid='6445' class='u'>save-excursion</a>
    <a id='6448' tid='6447' class='u'>;; 8. character address of start of comment or string; nil if not
</a>    <a id='6450' tid='6449' class='u'>;;    in one
</a>    (<a id='6452' tid='6451' class='u'>let</a> ((<a id='6454' tid='6453' class='u'>start</a> (<a id='6456' tid='6455' class='u'>nth</a> <a id='6458' tid='6457' class='u'>8</a> (<a id='6460' tid='6459' class='u'>or</a> <a id='6462' tid='6461' class='u'>state</a> (<a id='6464' tid='6463' class='u'>paredit-current-parse-state</a>)))))
      (<a id='6466' tid='6465' class='u'>goto-char</a> <a id='6468' tid='6467' class='u'>start</a>)
      (<a id='6470' tid='6469' class='u'>forward-sexp</a> <a id='6472' tid='6471' class='u'>1</a>)
      (<a id='6474' tid='6473' class='u'>cons</a> <a id='6476' tid='6475' class='u'>start</a> (<a id='6478' tid='6477' class='u'>1-</a> (<a id='6480' tid='6479' class='u'>point</a>))))))

(<a id='4078' tid='4077' class='u'>defun</a> <a id='4080' tid='4079' class='u'>paredit-in-comment-p</a> (<a id='4082' tid='4081' class='u'>&optional</a> <a id='4084' tid='4083' class='u'>state</a>)
  <a id='4086' tid='4085' class='u'>&quot;True if parse state STATE is within a comment.
If no parse state is supplied, compute one from the beginning of the
  defun to the point.&quot;</a>
  <a id='4088' tid='4087' class='u'>;; 4. nil if outside a comment, t if inside a non-nestable comment,
</a>  <a id='4090' tid='4089' class='u'>;;    else an integer (the current comment nesting)
</a>  (<a id='4092' tid='4091' class='u'>and</a> (<a id='4094' tid='4093' class='u'>nth</a> <a id='4096' tid='4095' class='u'>4</a> (<a id='4098' tid='4097' class='u'>or</a> <a id='4100' tid='4099' class='u'>state</a> (<a id='4102' tid='4101' class='u'>paredit-current-parse-state</a>)))
       <a id='4104' tid='4103' class='u'>t</a>))

(<a id='5652' tid='5651' class='u'>defun</a> <a id='5654' tid='5653' class='u'>paredit-point-at-sexp-boundary</a> (<a id='5656' tid='5655' class='u'>n</a>)
  (<a id='5658' tid='5657' class='u'>cond</a> ((<a id='5660' tid='5659' class='u'>&lt;</a> <a id='5662' tid='5661' class='u'>n</a> <a id='5664' tid='5663' class='u'>0</a>) (<a id='5666' tid='5665' class='u'>paredit-point-at-sexp-start</a>))
        ((<a id='5668' tid='5667' class='u'>=</a> <a id='5670' tid='5669' class='u'>n</a> <a id='5672' tid='5671' class='u'>0</a>) (<a id='5674' tid='5673' class='u'>point</a>))
        ((<a id='5676' tid='5675' class='u'>&gt;</a> <a id='5678' tid='5677' class='u'>n</a> <a id='5680' tid='5679' class='u'>0</a>) (<a id='5682' tid='5681' class='u'>paredit-point-at-sexp-end</a>))))

(<a id='5696' tid='5695' class='u'>defun</a> <a id='5698' tid='5697' class='u'>paredit-point-at-sexp-start</a> ()
  (<a id='5700' tid='5699' class='u'>save-excursion</a>
    (<a id='5702' tid='5701' class='u'>forward-sexp</a>)
    (<a id='5704' tid='5703' class='u'>backward-sexp</a>)
    (<a id='5706' tid='5705' class='u'>point</a>)))

(<a id='5684' tid='5683' class='u'>defun</a> <a id='5686' tid='5685' class='u'>paredit-point-at-sexp-end</a> ()
  (<a id='5688' tid='5687' class='u'>save-excursion</a>
    (<a id='5690' tid='5689' class='u'>backward-sexp</a>)
    (<a id='5692' tid='5691' class='u'>forward-sexp</a>)
    (<a id='5694' tid='5693' class='u'>point</a>)))

(<a id='5186' tid='5185' class='u'>defun</a> <a id='5188' tid='5187' class='u'>paredit-lose-if-not-in-sexp</a> (<a id='5190' tid='5189' class='u'>command</a>)
  (<a id='5192' tid='5191' class='u'>if</a> (<a id='5194' tid='5193' class='u'>or</a> (<a id='5196' tid='5195' class='u'>paredit-in-string-p</a>)
          (<a id='5198' tid='5197' class='u'>paredit-in-comment-p</a>)
          (<a id='5200' tid='5199' class='u'>paredit-in-char-p</a>))
      (<a id='5202' tid='5201' class='u'>error</a> <a id='5204' tid='5203' class='u'>&quot;Invalid context for command `%s&#39;.&quot;</a> <a id='5206' tid='5205' class='u'>command</a>)))

(<a id='2610' tid='2609' class='u'>defun</a> <a id='2612' tid='2611' class='u'>paredit-check-region</a> (<a id='2614' tid='2613' class='u'>start</a> <a id='2616' tid='2615' class='u'>end</a>)
  <span class='i'>&quot;Signal an error if text between `start&#39; and `end&#39; is unbalanced.&quot;</span>
  <span class='i'>;; `narrow-to-region&#39; will move the point, so avoid calling it if we
</span>  <span class='i'>;; don&#39;t need to.  We don&#39;t want to use `save-excursion&#39; because we
</span>  <span class='i'>;; want the point to move if `check-parens&#39; reports an error.
</span>  <span class='i'>(if (not (paredit-region-ok-p start end))
      (save-restriction
        (narrow-to-region start end)
        (check-parens)))</span>)

(<a id='5722' tid='5721' class='u'>defun</a> <a id='5724' tid='5723' class='u'>paredit-region-ok-p</a> (<a id='5726' tid='5725' class='u'>start</a> <a id='5728' tid='5727' class='u'>end</a>)
  <span class='i'>&quot;Return true iff the region between `start&#39; and `end&#39; is balanced.
This is independent of context -- it doesn&#39;t check what state the
  text at `start&#39; is in.&quot;</span>
  <span class='i'>(save-excursion
    (paredit-handle-sexp-errors
        (progn
          (save-restriction
            (narrow-to-region start end)
            (scan-sexps (point-min) (point-max)))
          t)
      nil))</span>)

<span class='i'>(defun paredit-current-indentation ()
  (save-excursion
    (back-to-indentation)
    (current-column)))</span>

<a id='7500' tid='7499' class='u'>;;;; Initialization
</a>
(<a id='7502' tid='7501' class='u'>paredit-define-keys</a>)
(<a id='7504' tid='7503' class='u'>paredit-annotate-mode-with-examples</a>)
(<a id='7506' tid='7505' class='u'>paredit-annotate-functions-with-examples</a>)

(<a id='7508' tid='7507' class='u'>provide</a> <a id='7510' tid='7509' class='u'>&#39;</a><a id='7512' tid='7511' class='u'>paredit</a>)

<a id='7514' tid='7513' class='u'>;;; Local Variables:
</a><a id='7516' tid='7515' class='u'>;;; outline-regexp: &quot;\n;;;;+&quot;
</a><a id='7518' tid='7517' class='u'>;;; End:
</a>
<a id='7520' tid='7519' class='u'>;;; paredit.el ends here
</a>
</pre>
</div>
</body>
</html>
